Jump to content

bparzella

Members
  • Gesamte Inhalte

    1
  • Benutzer seit

  • Letzter Besuch

Alle erstellten Inhalte von bparzella

  1. Hey, ich möchte die python Bindings mit zwei Verbindungen nutzen (WLAN + lokaler brickd). Jedoch bekomme ich sowohl unter Linux als auch unter OSX nach einer zufälligen Zeit die folgende Exception: Exception in thread Thread-2: Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 552, in __bootstrap_inner File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 505, in run File "/Users/bparzella/Developer/HomeManager/tinkerforge/ip_connection.py", line 247, in callback_loop device = self.devices[stack_id] KeyError: 4 Bei der Suche nach der Ursache bin ich darauf gestoßen, das die callback_queue als Klassenvariable angelegt ist. Das heißt das alle Instanzen sich diese Variable teilen. Das würde heißen das der Eintrag der Queue zufällig an eine der Instanzen verteilt würde. Wenn nun ein Callback für einen Stack mit 4 Bricklets an die Instanz eines Stacks mit nur 2 Bricklets verteilt wird, kann das unter Umständen die oben genannte Exception auftreten (Callback für stack_id > 2). Um es kurz zu machen sollte in der ip_connection.py die Variable als Objektvariable anstatt als Klassenvariable benutzt werden. Alt: PLUGIN_CHUNK_SIZE = 32 callback_queue = Queue() def __init__(self, host, port): """ Creates an IP connection to the Brick Daemon with the given *host* and *port*. With the IP connection itself it is possible to enumerate the available devices. Other then that it is only used to add Bricks and Bricklets to the connection. """ self.pending_add_device = None Neu: PLUGIN_CHUNK_SIZE = 32 def __init__(self, host, port): """ Creates an IP connection to the Brick Daemon with the given *host* and *port*. With the IP connection itself it is possible to enumerate the available devices. Other then that it is only used to add Bricks and Bricklets to the connection. """ self.callback_queue = Queue() self.pending_add_device = None Ich haben den Patch angehängt. Grüße Benjamin py_ipcon_multiple_connections.patch
×
×
  • Neu erstellen...