Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1c405b3

Browse files
committed
Followup to 51c1f2cedb96 (and issue #12456):
qsize() raises NotImplementedError on OS X, don't use it.
1 parent 4334d74 commit 1c405b3

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

Lib/concurrent/futures/process.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def shutdown_worker():
204204
# This is an upper bound
205205
nb_children_alive = sum(p.is_alive() for p in processes.values())
206206
for i in range(0, nb_children_alive):
207-
call_queue.put(None)
207+
call_queue.put_nowait(None)
208208
# If .join() is not called on the created processes then
209209
# some multiprocessing.Queue methods may deadlock on Mac OS X.
210210
for p in processes.values():
@@ -265,18 +265,18 @@ def shutdown_worker():
265265
# - The executor that owns this worker has been collected OR
266266
# - The executor that owns this worker has been shutdown.
267267
if shutting_down():
268-
# Since no new work items can be added, it is safe to shutdown
269-
# this thread if there are no pending work items.
270-
if not pending_work_items and call_queue.qsize() == 0:
271-
shutdown_worker()
272-
return
273268
try:
274-
# Start shutting down by telling a process it can exit.
275-
call_queue.put_nowait(None)
269+
# Since no new work items can be added, it is safe to shutdown
270+
# this thread if there are no pending work items.
271+
if not pending_work_items:
272+
shutdown_worker()
273+
return
274+
else:
275+
# Start shutting down by telling a process it can exit.
276+
call_queue.put_nowait(None)
276277
except Full:
277278
# This is not a problem: we will eventually be woken up (in
278-
# result_queue.get()) and be able to send a sentinel again,
279-
# if necessary.
279+
# result_queue.get()) and be able to send a sentinel again.
280280
pass
281281
executor = None
282282

0 commit comments

Comments
 (0)