diff options
author | Michele Simionato <michele.simionato@gmail.com> | 2011-01-12 09:26:38 +0100 |
---|---|---|
committer | Michele Simionato <michele.simionato@gmail.com> | 2011-01-12 09:26:38 +0100 |
commit | c5563182313e8be731a15e5cc08b90e33970893b (patch) | |
tree | 3457e0a52b0d989c245fa391c822b01c08a73ec7 | |
parent | f559460c6eeae60e231962730aad779a6ba5e205 (diff) | |
download | micheles-c5563182313e8be731a15e5cc08b90e33970893b.tar.gz |
Fixed the propagation of exceptions in Interpreter.__exit__
-rw-r--r-- | plac/plac_ext.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/plac/plac_ext.py b/plac/plac_ext.py index a7391d9..6678477 100644 --- a/plac/plac_ext.py +++ b/plac/plac_ext.py @@ -690,9 +690,9 @@ class Interpreter(object): self._interpreter.send(None) return self - def __exit__(self, *exc): + def __exit__(self, exctype, exc, tb): "Close the inner interpreter and the task manager" - self.close() + self.close(exctype, exc, tb) def submit(self, line): "Send a line to the underlying interpreter and return a task object" @@ -720,10 +720,13 @@ class Interpreter(object): "The full lists of the submitted tasks" return self.tm.registry.values() - def close(self): + def close(self, exctype=None, exc=None, tb=None): "Can be called to close the interpreter prematurely" self.tm.close() - self._interpreter.close() + if exctype is not None: + self._interpreter.throw(exctype, exc, tb) + else: + self._interpreter.close() def _make_interpreter(self): "The interpreter main loop, from lists of arguments to task objects" |