Skip to content

Commit 7bbeb0e

Browse files
committed
Re-working process worker
1 parent b93067b commit 7bbeb0e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

giskard/utils/worker_pool.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,18 @@ class GiskardResult:
9292
exception: Any = None
9393

9494

95-
def _process_worker(tasks_queue: SimpleQueue, tasks_results: SimpleQueue, running_process: Dict[str, str]):
95+
def _process_worker(
96+
tasks_queue: Queue[Optional[GiskardTask]], tasks_results: Queue[GiskardResult], running_process: Dict[str, str]
97+
):
9698
pid = os.getpid()
9799
LOGGER.info("Process %s started", pid)
98100

99101
while True:
100102
# Blocking accessor, will wait for a task
101-
task: GiskardTask = tasks_queue.get()
103+
try:
104+
task: Optional[GiskardTask] = tasks_queue.get(timeout=1)
105+
except Empty:
106+
continue
102107
# This is how we cleanly stop the workers
103108
if task is None:
104109
LOGGER.info("Process %s stopping", pid)

0 commit comments

Comments
 (0)