Skip to content

Commit

Permalink
Fixed traceback for futures
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Jun 22, 2018
1 parent c3db53e commit 3043b1c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions promise/promise.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@ def resolve(value):
# type: (T) -> None
self._resolve_callback(value)

def reject(reason):
# type: (Exception) -> None
self._reject_callback(reason, synchronous)
def reject(reason, traceback=None):
# type: (Exception, TracebackType) -> None
self._reject_callback(reason, synchronous, traceback)

error = None
traceback = None
Expand Down Expand Up @@ -827,9 +827,10 @@ def _process_future_result(resolve, reject):
# type: (Callable, Callable) -> Callable
def handle_future_result(future):
# type: (Any) -> None
exception = future.exception()
if exception:
reject(exception)
else:
try:
resolve(future.result())
except Exception as e:
tb = exc_info()[2]
reject(e, tb)

return handle_future_result

0 comments on commit 3043b1c

Please sign in to comment.