Synchronizing event requests with responses using the EvtSync class in ble_adapter.py is somewhat fragile in the following respects:
If an event response doesn't arrive before its timeout its just returns the data from the last event without any error raised (condition.wait() doesn't raise any timeout exceptions, in fact in python 2 there is no way to tell whether it timed out or not).
If an event response arrives before the waiting thread manages to enter its condition lock, we will miss it entirely.
The same data reference is handed out to all waiting threads. This is fine if data is immutable, but probably should be explicitly stated somewhere.
Only a single reference is used to hold event data for all possible events. This opens the possibility of race conditions where the waiter receives event data from the wrong event.
Currently the most alarming issue is that if the event wait times out, data from the previously handled event is returned without any error raised. This can lead to very hard to diagnose bugs.
Synchronizing event requests with responses using the EvtSync class in ble_adapter.py is somewhat fragile in the following respects:
Currently the most alarming issue is that if the event wait times out, data from the previously handled event is returned without any error raised. This can lead to very hard to diagnose bugs.