Skip to content
Open
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
5 changes: 4 additions & 1 deletion SolixBLE/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ async def connect(self, max_attempts: int = 3, run_callbacks: bool = True) -> bo
self._auto_reconnect_task = asyncio.create_task(self._auto_reconnect())

# Start a keep-alive task if its not running already
if self._keep_alive_task is None:
# (The task ends by itself when the connection drops, so restart it on
# every successful (re)connection, not just the first.)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I never noticed this happened.

if self._keep_alive_task is None or self._keep_alive_task.done():
self._keep_alive_task = asyncio.create_task(self._keep_alive_fn())

# Execute callbacks if enabled
Expand Down Expand Up @@ -310,6 +312,7 @@ async def disconnect(self) -> None:
# Cancel the keep-alive task
if self._keep_alive_task is not None:
self._keep_alive_task.cancel()
self._keep_alive_task = None

# If there is a client disconnect and throw it away
if self._client is not None:
Expand Down
Loading