×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    3

    Python 1.4.5 -> 1.9.4 breaks bluetooth socket closing behaviour

    Hi chaps,

    We're looking to upgrade from 1.4.5 to 1.9.4 in order to benefit from some of the Python core 2.5.2 functionality, but in doing so some of the socket behaviour in our code has broken. Here are the relevant code snippets (apologies if the indentation formatting gets broken) .

    We import the btsocket module as:

    Code:
        import btsocket as socket
    and instantiate a socket via:

    Code:
      sock = socket.socket(socket.AF_BT, socket.SOCK_STREAM)
    Data packets are then read via calls to the function:

    Code:
      def receivePacket(sock):
        buffer = ""
        packetComplete = False
    
        while not packetComplete :
          try:
           ch = sock.recv(1)
          except:
            print "error communicating with sensor"
            continue
    
          # loop until packet received
          while(ch != '\n'):
            buffer += ch
            try:
              ch = sock.recv(1)
            except:
              print "error communicating with sensor"
              continue
    
          packetComplete = True
    
        return buffer
    We also register a Disconnect function via the atexit module for when we terminate the application, which has the form:

    Code:
      def Disconnect():
        global sock,
    
        # Close the Bluetooth socket
        sock.close()
    
        # other code removed
    Now with 1.4.5 everything stops working cleanly when Disconnect is invoked, but with 1.9.4 the diagnostic string "error communicating with sensor" gets echoed (doesn't happen with 1.4.5) and the whole phone freezes up. Only rebooting the phone is then possible. Why does the thread of execution return to the receivePacket function in 1.9.4 when the function registered with atexit has been invoked? Is this a bug in 1.9.4?

    Regards,
    m

  2. #2
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    114

    Re: Python 1.4.5 -> 1.9.4 breaks bluetooth socket closing behaviour

    Quote Originally Posted by m_c_001 View Post
    ... with 1.9.4 the diagnostic string "error communicating with sensor" gets echoed (doesn't happen with 1.4.5) and the whole phone freezes up. Only rebooting the phone is then possible. Why does the thread of execution return to the receivePacket function in 1.9.4 when the function registered with atexit has been invoked? Is this a bug in 1.9.4?

    Regards,
    m
    Try to write the exception raised to a file and check the traceback. What does it say?
    import antigravity

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    3

    Re: Python 1.4.5 -> 1.9.4 breaks bluetooth socket closing behaviour

    Changing the except clauses in receivePacket to print the exception message rather than the string in the original listing, i.e. the two clauses now read:
    Code:
        except Exception, e:
          print "%s" % (e)
    now displays the following prior to the phone freezing up:
    Code:
    (13, 'Permission denied')
    Is this related to the problem described at the following link?

    https://garage.maemo.org/tracker/ind...=854&atid=3201

    m

  4. #4
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: Python 1.4.5 -> 1.9.4 breaks bluetooth socket closing behaviour

    Quote Originally Posted by m_c_001 View Post

    Is this related to the problem described at the following link?

    https://garage.maemo.org/tracker/ind...=854&atid=3201

    m
    Looks like its the same bug, but if your observations are different from those mentioned in the bug tracker please update the tracker.

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    3

    Re: Python 1.4.5 -> 1.9.4 breaks bluetooth socket closing behaviour

    Looks like its the same bug, but if your observations are different from those mentioned in the bug tracker please update the tracker.
    OK, report filed.

Similar Threads

  1. Replies: 21
    Last Post: 2011-03-17, 08:16
  2. Replies: 32
    Last Post: 2007-07-19, 07:43
  3. Replies: 1
    Last Post: 2006-09-19, 23:41
  4. Replies: 0
    Last Post: 2006-09-19, 15:15
  5. Replies: 10
    Last Post: 2006-08-08, 17:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×