Skip to content

Instantly share code, notes, and snippets.

@j2labs
Created August 2, 2011 17:12
Show Gist options
  • Save j2labs/1120681 to your computer and use it in GitHub Desktop.
Save j2labs/1120681 to your computer and use it in GitHub Desktop.
one shot continuation, sorta, using python greenlets
#!/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