driver: wait for the read_response task to complete before connection retry

This commit is contained in:
linuswck 2025-01-21 11:27:48 +08:00
parent 7dd551201e
commit 2a6db53dc8

View File

@ -773,6 +773,7 @@ class Kirdy:
async def _handler(self): async def _handler(self):
try: try:
self._state = State.disconnected self._state = State.disconnected
self.read_response_task = None
first_con = True first_con = True
task = None task = None
while True: while True:
@ -811,6 +812,7 @@ class Kirdy:
logging.warning("Connection to Kirdy is dropped.") logging.warning("Connection to Kirdy is dropped.")
first_con = True first_con = True
self.read_response_task.cancel() self.read_response_task.cancel()
await self.read_response_task
# State Transition # State Transition
self._state = State.disconnected self._state = State.disconnected