aioble/device.py: Always create connection._event.

If the client disconnects immediately after connection, the irq can be run
before the initial connect handler has finished.
pull/471/head
Andrew Leech 2022-09-16 12:11:25 +10:00 zatwierdzone przez Damien George
rodzic f0b683218e
commit e7f605df33
1 zmienionych plików z 1 dodań i 4 usunięć

Wyświetl plik

@ -164,7 +164,7 @@ class DeviceConnection:
# This event is fired by the IRQ both for connection and disconnection
# and controls the device_task.
self._event = None
self._event = asyncio.ThreadSafeFlag()
# If we're waiting for a pending MTU exchange.
self._mtu_event = None
@ -207,9 +207,6 @@ class DeviceConnection:
t._task.cancel()
def _run_task(self):
# Event will be already created this if we initiated connection.
self._event = self._event or asyncio.ThreadSafeFlag()
self._task = asyncio.create_task(self.device_task())
async def disconnect(self, timeout_ms=2000):