X-Git-Url: https://git.ralfj.de/saartuer.git/blobdiff_plain/0889e9a1ec6bda2c4b16dabf0ab40793ac17756c..d084286e81b121106a0a165e3c151762635466e0:/libtuer.py diff --git a/libtuer.py b/libtuer.py index 01c04ae..f79dcc6 100644 --- a/libtuer.py +++ b/libtuer.py @@ -111,6 +111,13 @@ class ThreadFunction(): self._q.put((ThreadFunction._CALL, arg)) def stop(self): + # empty the queue + try: + while True: + self._q.get_nowait() + except queue.Empty: + pass + # now wait till the job-in-progress is done self._q.put((ThreadFunction._TERM, None)) self._t.join()