Skip to content

Commit

Permalink
asyncCheck(): don't raise exception on cancellation (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefantalpalaru authored Aug 12, 2020
1 parent 284d677 commit baf33f0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions chronos/asyncfutures2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -531,13 +531,11 @@ proc mget*[T](future: FutureVar[T]): var T =
result = Future[T](future).value

proc asyncCheck*[T](future: Future[T]) =
## Sets a callback on ``future`` which raises an exception if the future
## finished with an error.
##
## This should be used instead of ``discard`` to discard void futures.
## Sets a callback on ``future`` which raises an exception in ``poll()`` if the
## future failed.
doAssert(not isNil(future), "Future is nil")
proc cb(data: pointer) =
if future.failed() or future.cancelled():
if future.failed():
when defined(chronosStackTrace):
injectStacktrace(future)
raise future.error
Expand Down

0 comments on commit baf33f0

Please sign in to comment.