From 311fa6642031a4fea1cdc529218059b5753803bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Tue, 2 Sep 2025 07:52:30 -0400 Subject: [PATCH] Update taskmanagers.py --- qtapputils/managers/taskmanagers.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/qtapputils/managers/taskmanagers.py b/qtapputils/managers/taskmanagers.py index 7ca3175..254e727 100644 --- a/qtapputils/managers/taskmanagers.py +++ b/qtapputils/managers/taskmanagers.py @@ -14,6 +14,7 @@ # ---- Standard imports from collections import OrderedDict import uuid +from time import sleep # ---- Third party imports from qtpy.QtCore import QObject, QThread, Signal @@ -203,11 +204,13 @@ def _run_pending_tasks(self): # Even though the worker has executed all its tasks, # we may still need to wait a little for it to stop properly. - try: - qtwait(lambda: not self._thread.isRunning(), timeout=10) - except TimeoutError: - print("Error: unable to stop {}'s working thread.".format( - self.__class__.__name__)) + i = 0 + while self._thread.isRunning(): + sleep(0.1) + i += 1 + if i > 100: + print("Error: unable to stop {}'s working thread.".format( + self.__class__.__name__)) self._running_tasks = self._pending_tasks.copy() self._pending_tasks = []