Skip to content

Instantly share code, notes, and snippets.

@l04m33
Created March 4, 2015 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l04m33/617bf88e3c74a88bd59b to your computer and use it in GitHub Desktop.
Save l04m33/617bf88e3c74a88bd59b to your computer and use it in GitHub Desktop.
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