@@ -471,17 +471,15 @@ def terminate_broken(self, cause):
471471 executor ._shutdown_thread = True
472472 executor = None
473473
474- # All pending tasks are to be marked failed with the following
475- # BrokenProcessPool error
476- bpe = BrokenProcessPool ("A process in the process pool was "
477- "terminated abruptly while the future was "
478- "running or pending." )
479- if cause is not None :
480- bpe .__cause__ = _RemoteTraceback (
481- f"\n '''\n { '' .join (cause )} '''" )
482-
483474 # Mark pending tasks as failed.
484475 for work_id , work_item in self .pending_work_items .items ():
476+ bpe = BrokenProcessPool (
477+ "A process in the process pool was "
478+ "terminated abruptly while the future was "
479+ "running or pending." )
480+ if cause is not None :
481+ bpe .__cause__ = _RemoteTraceback (
482+ f"\n '''\n { '' .join (cause )} '''" )
485483 work_item .future .set_exception (bpe )
486484 # Delete references to object. See issue16284
487485 del work_item
@@ -762,7 +760,8 @@ def _spawn_process(self):
762760 def submit (self , fn , / , * args , ** kwargs ):
763761 with self ._shutdown_lock :
764762 if self ._broken :
765- raise BrokenProcessPool (self ._broken )
763+ raise BrokenProcessPool (
764+ 'cannot schedule new futures after process pool has broken' )
766765 if self ._shutdown_thread :
767766 raise RuntimeError ('cannot schedule new futures after shutdown' )
768767 if _global_shutdown :
0 commit comments