X-Git-Url: https://git.ralfj.de/saartuer.git/blobdiff_plain/0889e9a1ec6bda2c4b16dabf0ab40793ac17756c..b43971d227ed5ab3e86ae29f3496e84d07edd202:/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()