From: Alexander Schmidt Date: Sat, 3 Oct 2020 09:31:59 +0000 (+0200) Subject: avoid race condition on stop X-Git-Url: http://git.treefish.org/~alex/mtxbot.git/commitdiff_plain/3bc600aca376ed27dd4466da362b62b098f7c3ec?ds=inline avoid race condition on stop --- diff --git a/src/presence.py b/src/presence.py index 0a7b1a1..4c7e966 100644 --- a/src/presence.py +++ b/src/presence.py @@ -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: