@@ -299,12 +299,13 @@ def _join_exited_workers(pool, outqueue, job_assignments):
299
299
pid = worker .ident
300
300
worker .join ()
301
301
cleaned = True
302
- if pid in job_assignments :
302
+ job_info = job_assignments .pop (pid ,None )
303
+ if job_info is not None :
303
304
# If the worker process died without communicating back
304
305
# 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
- del job_assignments [ pid ]
306
+ outqueue . put (
307
+ ( * job_info , (False ,RuntimeError ("Worker died" )))
308
+ )
308
309
del pool [i ]
309
310
return cleaned
310
311
@@ -602,7 +603,7 @@ def _handle_results(outqueue, get, cache, job_assignments):
602
603
# task_info is True or False when a task has completed but
603
604
# None indicates information about which process has
604
605
# accepted a job from the queue.
605
- job_assignments [value ]= job
606
+ job_assignments [value ]= ( job , i )
606
607
else :
607
608
try :
608
609
cache [job ]._set (i , (task_info ,value ))
@@ -623,7 +624,7 @@ def _handle_results(outqueue, get, cache, job_assignments):
623
624
624
625
job ,i , (task_info ,value )= task
625
626
if task_info is None :
626
- job_assignments [value ]= job
627
+ job_assignments [value ]= ( job , i )
627
628
else :
628
629
try :
629
630
cache [job ]._set (i , (task_info ,value ))