Created
March 4, 2015 10:04
-
-
Save l04m33/617bf88e3c74a88bd59b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncdispatch, math | |
randomize() | |
proc r1() {.async.} = | |
echo("r1 going to sleep....") | |
await sleepAsync(random(1000) + 500) | |
if true: | |
raise newException(ValueError, "Oops!") | |
echo("r1 is awake.") | |
proc r2() {.async.} = | |
echo("r2 entry") | |
try: | |
await r1() | |
except ValueError: | |
echo("r1 raised an exception!!!!") | |
echo("r2 return") | |
waitFor(r2()) | |
echo("Done.") | |
# ========= Output ========= | |
# r2 entry | |
# r1 going to sleep.... | |
# r1 raised an exception!!!! | |
# r2 return | |
# Traceback (most recent call last) | |
# async.nim(20) async | |
# asyncdispatch.nim(1378) waitFor | |
# asyncdispatch.nim(911) poll | |
# asyncdispatch.nim(319) processTimers | |
# asyncdispatch.nim(195) complete | |
# asyncdispatch.nim(1082) cb | |
# SIGSEGV: Illegal storage access. (Try to compile with -d:useSysAssert -d:useGcAssert for details.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment