asyncCheck(): don't raise exception on cancellation (#121)

This commit is contained in:
Ștefan Talpalaru 2020-08-12 16:24:55 +02:00 committed by GitHub
parent 284d677815
commit baf33f04ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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