diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-11-20 13:49:19 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-11-20 13:49:19 +0100 |
commit | fca11e3534eca930e1adeebb74b1c039e983542b (patch) | |
tree | 2cb8aea550431c695c830fc07befc65fbe29f7cf | |
parent | 0ffdda2b9ac21d1341dfb8def0405a283ee36596 (diff) | |
download | trollius-fca11e3534eca930e1adeebb74b1c039e983542b.tar.gz |
In debug mode, Future.set_exception() now formats the exception traceback if it
is known, instead of using the current stack. So when a task waits for a second
task and the second task raises an exception, the first task keeps the
traceback of the second task, which is more useful.
-rw-r--r-- | trollius/futures.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/trollius/futures.py b/trollius/futures.py index 02514f2..a771057 100644 --- a/trollius/futures.py +++ b/trollius/futures.py @@ -389,7 +389,10 @@ class Future(object): if self._loop.get_debug(): frame = sys._getframe(1) tb = ['Traceback (most recent call last):\n'] - tb += traceback.format_stack(frame) + if self._exception_tb is not None: + tb += traceback.format_tb(self._exception_tb) + else: + tb += traceback.format_stack(frame) tb += traceback.format_exception_only(type(exception), exception) self._tb_logger.tb = tb else: |