Skip to content

Commit c4b771a

Browse files
committed
clean up exc_wrapper with minimal indentation
1 parent d5e8c7a commit c4b771a

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

Lib/concurrent/futures/interpreter.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -179,37 +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:
182190
try:
183-
self._exec(script)
184-
except ExecutionFailed as exc:
185-
exc_wrapper = exc
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
186200
else:
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
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+
try:
209209
raise pickle.loads(excdata) from exc_wrapper
210-
return pickle.loads(res) if pickled else res
211-
finally:
212-
exc_wrapper = None
210+
finally:
211+
exc_wrapper = None
212+
return pickle.loads(res) if pickled else res
213213

214214

215215
class BrokenInterpreterPool(_thread.BrokenThreadPool):

0 commit comments

Comments
 (0)