Created
January 10, 2018 01:34
-
-
Save RedBeard0531/257097035edf06205b13c2e89c376ab1 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
# nim check -d=nimDumpAsync input.nim | |
proc foo(): Future[void] = | |
var retFuture259001 = newFuture[void]("foo") | |
iterator fooIter259002(): FutureBase {.closure.} = | |
echo "before await" | |
var future259003 = newFuture[void]() | |
yield future259003 | |
if future259003.failed: | |
setCurrentException(future259003.error) | |
if future259003.error of Exception: | |
echo "Exception" | |
elif true: | |
echo "except" | |
elif true: | |
echo "finally" | |
elif true: | |
raise future259003.error | |
setCurrentException(nil) | |
else: | |
try: | |
future259003.read | |
echo "after await" | |
except Exception: | |
echo "Exception" | |
except: | |
echo "except" | |
finally: | |
echo "finally" | |
complete(retFuture259001) | |
var nameIterVar259006 = fooIter259002 | |
proc foo_continue259004() {.closure.} = | |
try: | |
if notnameIterVar259006.finished: | |
var next259008 = nameIterVar259006() | |
if next259008 == | |
nil: | |
if notretFuture259001.finished: | |
let msg259010 = "Async procedure ($1) yielded `nil`, are you await\'ing a " & | |
"`nil` Future?" | |
raise newException(AssertionError, msg259010 % "foo") | |
else: | |
{.gcsafe.}: | |
{.push, hint[ConvFromXtoItselfNotNeeded]: off.} | |
next259008.callback = (proc () {.closure, gcsafe.})(foo_continue259004) | |
{.pop.} | |
except: | |
if retFuture259001.finished: | |
raise | |
else: | |
retFuture259001.fail(getCurrentException()) | |
foo_continue259004() | |
return retFuture259001 |
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 | |
proc foo(): Future[void] {.async.} = | |
try: | |
echo "before await" | |
await newFuture[void]() | |
echo "after await" | |
except Exception: | |
echo "Exception" | |
except: | |
echo "except" | |
finally: | |
echo "finally" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment