summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-11-20 13:49:19 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-11-20 13:49:19 +0100
commitfca11e3534eca930e1adeebb74b1c039e983542b (patch)
tree2cb8aea550431c695c830fc07befc65fbe29f7cf
parent0ffdda2b9ac21d1341dfb8def0405a283ee36596 (diff)
downloadtrollius-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.py5
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: