From 1226cca6e63ae6ed0a9fefc2f186a2a1fbd0d086 Mon Sep 17 00:00:00 2001 From: atse Date: Tue, 18 Jul 2023 11:21:32 +0800 Subject: [PATCH] Only set connecting task to None once --- pytec/pytec/aioclient.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pytec/pytec/aioclient.py b/pytec/pytec/aioclient.py index 42da5d5..f65b150 100644 --- a/pytec/pytec/aioclient.py +++ b/pytec/pytec/aioclient.py @@ -27,7 +27,8 @@ class Client: self._reader, self._writer = await self._connecting_task except asyncio.CancelledError: return False - self._connecting_task = None + finally: + self._connecting_task = None await self._check_zero_limits() return True @@ -44,7 +45,6 @@ class Client: """Disconnect the client if connected, cancel connection if connecting""" if self._connecting_task is not None: self._connecting_task.cancel() - self._connecting_task = None return if self._writer is None: