@@ -179,34 +179,37 @@ def run(self, task):
179179 raise NotImplementedError (kind )
180180
181181 try :
182- self ._exec (script )
183- except ExecutionFailed as exc :
184- exc_wrapper = exc
185- else :
186- exc_wrapper = None
187-
188- # Return the result, or raise the exception.
189- while True :
190182 try :
191- obj = _interpqueues .get (self .resultsid )
192- except _interpqueues .QueueNotFoundError :
193- raise # re-raise
194- except _interpqueues .QueueError :
195- continue
196- except ModuleNotFoundError :
197- # interpreters.queues doesn't exist, which means
198- # QueueEmpty doesn't. Act as though it does.
199- continue
183+ self ._exec (script )
184+ except ExecutionFailed as exc :
185+ exc_wrapper = exc
200186 else :
201- break
202- (res , excdata ), pickled , unboundop = obj
203- assert unboundop is None , unboundop
204- if excdata is not None :
205- assert res is None , res
206- assert pickled
207- assert exc_wrapper is not None
208- raise pickle .loads (excdata ) from exc_wrapper
209- return pickle .loads (res ) if pickled else res
187+ exc_wrapper = None
188+
189+ # Return the result, or raise the exception.
190+ while True :
191+ try :
192+ obj = _interpqueues .get (self .resultsid )
193+ except _interpqueues .QueueNotFoundError :
194+ raise # re-raise
195+ except _interpqueues .QueueError :
196+ continue
197+ except ModuleNotFoundError :
198+ # interpreters.queues doesn't exist, which means
199+ # QueueEmpty doesn't. Act as though it does.
200+ continue
201+ else :
202+ break
203+ (res , excdata ), pickled , unboundop = obj
204+ assert unboundop is None , unboundop
205+ if excdata is not None :
206+ assert res is None , res
207+ assert pickled
208+ assert exc_wrapper is not None
209+ raise pickle .loads (excdata ) from exc_wrapper
210+ return pickle .loads (res ) if pickled else res
211+ finally :
212+ exc_wrapper = None
210213
211214
212215class BrokenInterpreterPool (_thread .BrokenThreadPool ):
0 commit comments