Skip to content

Commit 75d3cfa

Browse files
Merge pull request #38 from geo-stack/restore_worker_wait
PR: Restore taskmanagers wait loop
2 parents dd0369e + 311fa66 commit 75d3cfa

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

qtapputils/managers/taskmanagers.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# ---- Standard imports
1515
from collections import OrderedDict
1616
import uuid
17+
from time import sleep
1718

1819
# ---- Third party imports
1920
from qtpy.QtCore import QObject, QThread, Signal
@@ -203,11 +204,13 @@ def _run_pending_tasks(self):
203204

204205
# Even though the worker has executed all its tasks,
205206
# we may still need to wait a little for it to stop properly.
206-
try:
207-
qtwait(lambda: not self._thread.isRunning(), timeout=10)
208-
except TimeoutError:
209-
print("Error: unable to stop {}'s working thread.".format(
210-
self.__class__.__name__))
207+
i = 0
208+
while self._thread.isRunning():
209+
sleep(0.1)
210+
i += 1
211+
if i > 100:
212+
print("Error: unable to stop {}'s working thread.".format(
213+
self.__class__.__name__))
211214

212215
self._running_tasks = self._pending_tasks.copy()
213216
self._pending_tasks = []

0 commit comments

Comments
 (0)