Skip to content

Commit

Permalink
Check that _misc_task is not None before trying to cancel it. #39
Browse files Browse the repository at this point in the history
  • Loading branch information
flyte authored and frederikaalund committed Feb 24, 2021
1 parent f603b70 commit 3307297
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions asyncio_mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ def cb():

def _on_socket_close(self, client, userdata, sock):
self._loop.remove_reader(sock.fileno())
with suppress(asyncio.CancelledError):
self._misc_task.cancel()
if self._misc_task is not None:
with suppress(asyncio.CancelledError):
self._misc_task.cancel()

def _on_socket_register_write(self, client, userdata, sock):
def cb():
Expand Down

0 comments on commit 3307297

Please sign in to comment.