Skip to content

Commit

Permalink
Create _misc_loop() task thread safely. Fixes empicano#39
Browse files Browse the repository at this point in the history
  • Loading branch information
flyte committed Feb 24, 2021
1 parent f521691 commit 478d182
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion asyncio_mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ def _on_socket_open(self, client, userdata, sock):
def cb():
client.loop_read()
self._loop.add_reader(sock.fileno(), cb)
self._misc_task = self._loop.create_task(self._misc_loop())
def create_task_cb():
self._misc_task = self._loop.create_task(self._misc_loop())
self._loop.call_soon_threadsafe(create_task_cb)

def _on_socket_close(self, client, userdata, sock):
self._loop.remove_reader(sock.fileno())
Expand Down

0 comments on commit 478d182

Please sign in to comment.