mqtt: fix non-threadsafe on_socket_open callback

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2021-12-11 14:31:10 -05:00
parent c6cddf4b05
commit a4abec43d5
1 changed files with 6 additions and 0 deletions

View File

@ -94,6 +94,12 @@ class AIOHelper:
userdata: Any,
sock: socket.socket
) -> None:
self.loop.call_soon_threadsafe(
self._do_socket_open, client, sock)
def _do_socket_open(self,
client: paho_mqtt.Client,
sock: socket.socket) -> None:
logging.info("MQTT Socket Opened")
self.loop.add_reader(sock, client.loop_read)
self.misc_task = self.loop.create_task(self.misc_loop())