home · contact · privacy
Ensure loop threads are finished before returning from their context.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 30 May 2025 12:22:51 +0000 (14:22 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 30 May 2025 12:22:51 +0000 (14:22 +0200)
ircplom.py

index 53b0788168a9f8ae06a5ebde6c919f16bcba927e..48bf8e97d01cf95aa7fb66a78c51e80639a4e40a 100755 (executable)
@@ -280,13 +280,15 @@ class Loop:
         self._q_to_main = q_to_main
         self._bonus_iterator = bonus_iterator
         self._q_input: SimpleQueue[Event] = SimpleQueue()
-        Thread(target=self._loop, daemon=False).start()
+        self._thread = Thread(target=self._loop, daemon=False)
+        self._thread.start()
 
     def __enter__(self) -> Self:
         return self
 
     def __exit__(self, *_) -> Literal[False]:
         self._q_input.put(Event('QUIT'))
+        self._thread.join()
         return False  # re-raise any exception that above ignored
 
     def put(self, event: Event) -> None: