Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions pc_ble_driver_py/ble_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,22 @@ def __repr__(self):
class EvtSync(object):
def __init__(self, events):
self.conds = dict()
self.data = dict()
for evt in events:
self.conds[evt] = Condition(Lock())
self.data = None
self.data[evt] = None

def wait(self, evt, timeout=8):
self.data = None
with self.conds[evt]:
self.conds[evt].wait(timeout=timeout)
return self.data
if self.data[evt] is None:
self.conds[evt].wait(timeout=timeout)
result = self.data[evt]
self.data[evt] = None
return result

def notify(self, evt, data=None):
with self.conds[evt]:
self.data = data
self.data[evt] = data
self.conds[evt].notify_all()


Expand Down