]> git.treefish.org Git - mtxbot.git/blobdiff - src/presence.py
avoid race condition on stop
[mtxbot.git] / src / presence.py
index 0a7b1a13888f5085d44431911c9c1c9a9d7da380..4c7e966a5d9cd4de89439d4662a4fb425a772c5a 100644 (file)
@@ -21,6 +21,11 @@ class Presence:
         self._log(logging.INFO, "Presence stopped")
 
     def stop(self):
+        asyncio.get_running_loop().call_soon_threadsafe(
+            Presence._do_stop, self
+        )
+
+    def _do_stop(self):
         self._stop = True
         fifo = -1
         try: