Created
August 2, 2011 17:12
-
-
Save j2labs/1120681 to your computer and use it in GitHub Desktop.
one shot continuation, sorta, using python greenlets
This file contains hidden or 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
#!/usr/bin/env python | |
from greenlet import greenlet | |
def test1(coro): | |
print 'test1: 1' | |
coro_self = greenlet.getcurrent() | |
coro.switch(coro_self) | |
raise Exception('Hey you cant do this!') | |
def test2(coro): | |
print 'test2: 1' | |
coro_self = greenlet.getcurrent() | |
coro.switch(coro_self) | |
print 'test2: 2' | |
gr1 = greenlet(test1) | |
gr2 = greenlet(test2) | |
gr1.switch(gr2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment