Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6459284

Browse files
committed
Fix result position for killed workers, add Steve suggested change to use dict.pop().
1 parente1a9eb5 commit6459284

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

‎Lib/multiprocessing/pool.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,13 @@ def _join_exited_workers(pool, outqueue, job_assignments):
299299
pid=worker.ident
300300
worker.join()
301301
cleaned=True
302-
ifpidinjob_assignments:
302+
job_info=job_assignments.pop(pid,None)
303+
ifjob_infoisnotNone:
303304
# If the worker process died without communicating back
304305
# while running a job, add a default result for it.
305-
job=job_assignments[pid]
306-
outqueue.put((job,i,(False,RuntimeError("Worker died"))))
307-
deljob_assignments[pid]
306+
outqueue.put(
307+
(*job_info,(False,RuntimeError("Worker died")))
308+
)
308309
delpool[i]
309310
returncleaned
310311

@@ -602,7 +603,7 @@ def _handle_results(outqueue, get, cache, job_assignments):
602603
# task_info is True or False when a task has completed but
603604
# None indicates information about which process has
604605
# accepted a job from the queue.
605-
job_assignments[value]=job
606+
job_assignments[value]=(job,i)
606607
else:
607608
try:
608609
cache[job]._set(i, (task_info,value))
@@ -623,7 +624,7 @@ def _handle_results(outqueue, get, cache, job_assignments):
623624

624625
job,i, (task_info,value)=task
625626
iftask_infoisNone:
626-
job_assignments[value]=job
627+
job_assignments[value]=(job,i)
627628
else:
628629
try:
629630
cache[job]._set(i, (task_info,value))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp