Skip to content

Commit 09e0c29

Browse files
committed
Fix RuntimeError about Future being attached to different loop
This fixes an error about RuntimeError: Task <Task pending name='Task-8' coro=<Event.wait() running at /usr/lib64/python3.8/asyncio/locks.py:309> cb=[_release_waiter(<Future pendi...8094c9070>()]>)() at /usr/lib64/python3.8/asyncio/tasks.py:429]> got Future <Future pending> attached to a different loop in await asyncio.wait_for(self._notifyevent.wait(), timeout) at bleakconnection.py, line 101
1 parent 9461b0b commit 09e0c29

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

eq3bt/bleakconnection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def __init__(self, mac, iface):
3131
self._mac = mac
3232
self._iface = iface
3333
self._callbacks = {}
34-
self._notifyevent = asyncio.Event()
35-
self._notification_handle = None
3634

3735
try:
3836
self._loop = asyncio.get_running_loop()
3937
except RuntimeError:
4038
self._loop = asyncio.new_event_loop()
4139
asyncio.set_event_loop(self._loop)
40+
self._notifyevent = asyncio.Event(loop=self._loop)
41+
self._notification_handle = None
4242

4343
def __enter__(self):
4444
"""

0 commit comments

Comments
 (0)