Skip to content

Commit f6d4a47

Browse files
committed
Protect wakeup() call with shutdown_lock in _on_queue_feeder_error
1 parent 925e522 commit f6d4a47

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

loky/process_executor.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,11 @@ def __init__(
306306
pending_work_items=None,
307307
running_work_items=None,
308308
thread_wakeup=None,
309+
shutdown_lock=None,
309310
reducers=None,
310311
):
311312
self.thread_wakeup = thread_wakeup
313+
self.shutdown_lock = shutdown_lock
312314
self.pending_work_items = pending_work_items
313315
self.running_work_items = running_work_items
314316
super().__init__(max_size, reducers=reducers, ctx=ctx)
@@ -337,7 +339,8 @@ def _on_queue_feeder_error(self, e, obj):
337339
if work_item is not None:
338340
work_item.future.set_exception(raised_error)
339341
del work_item
340-
self.thread_wakeup.wakeup()
342+
with self.shutdown_lock:
343+
self.thread_wakeup.wakeup()
341344
else:
342345
super()._on_queue_feeder_error(e, obj)
343346

@@ -1167,6 +1170,7 @@ def _setup_queues(self, job_reducers, result_reducers, queue_size=None):
11671170
pending_work_items=self._pending_work_items,
11681171
running_work_items=self._running_work_items,
11691172
thread_wakeup=self._executor_manager_thread_wakeup,
1173+
shutdown_lock=self._shutdown_lock,
11701174
reducers=job_reducers,
11711175
ctx=self._context,
11721176
)

0 commit comments

Comments
 (0)