mirror of
https://github.com/python/cpython.git
synced 2025-10-03 05:35:59 +00:00
Followup to 51c1f2cedb96 (and issue #12456):
qsize() raises NotImplementedError on OS X, don't use it.
This commit is contained in:
parent
4334d740ed
commit
1c405b3e60
1 changed files with 10 additions and 10 deletions
|
@ -204,7 +204,7 @@ def _queue_management_worker(executor_reference,
|
||||||
# This is an upper bound
|
# This is an upper bound
|
||||||
nb_children_alive = sum(p.is_alive() for p in processes.values())
|
nb_children_alive = sum(p.is_alive() for p in processes.values())
|
||||||
for i in range(0, nb_children_alive):
|
for i in range(0, nb_children_alive):
|
||||||
call_queue.put(None)
|
call_queue.put_nowait(None)
|
||||||
# If .join() is not called on the created processes then
|
# If .join() is not called on the created processes then
|
||||||
# some multiprocessing.Queue methods may deadlock on Mac OS X.
|
# some multiprocessing.Queue methods may deadlock on Mac OS X.
|
||||||
for p in processes.values():
|
for p in processes.values():
|
||||||
|
@ -265,18 +265,18 @@ def _queue_management_worker(executor_reference,
|
||||||
# - The executor that owns this worker has been collected OR
|
# - The executor that owns this worker has been collected OR
|
||||||
# - The executor that owns this worker has been shutdown.
|
# - The executor that owns this worker has been shutdown.
|
||||||
if shutting_down():
|
if shutting_down():
|
||||||
|
try:
|
||||||
# Since no new work items can be added, it is safe to shutdown
|
# Since no new work items can be added, it is safe to shutdown
|
||||||
# this thread if there are no pending work items.
|
# this thread if there are no pending work items.
|
||||||
if not pending_work_items and call_queue.qsize() == 0:
|
if not pending_work_items:
|
||||||
shutdown_worker()
|
shutdown_worker()
|
||||||
return
|
return
|
||||||
try:
|
else:
|
||||||
# Start shutting down by telling a process it can exit.
|
# Start shutting down by telling a process it can exit.
|
||||||
call_queue.put_nowait(None)
|
call_queue.put_nowait(None)
|
||||||
except Full:
|
except Full:
|
||||||
# This is not a problem: we will eventually be woken up (in
|
# This is not a problem: we will eventually be woken up (in
|
||||||
# result_queue.get()) and be able to send a sentinel again,
|
# result_queue.get()) and be able to send a sentinel again.
|
||||||
# if necessary.
|
|
||||||
pass
|
pass
|
||||||
executor = None
|
executor = None
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue