Skip to content

Instantly share code, notes, and snippets.

@edwardgeorge
Created August 11, 2012 12:07
Show Gist options
  • Save edwardgeorge/3324089 to your computer and use it in GitHub Desktop.
Save edwardgeorge/3324089 to your computer and use it in GitHub Desktop.
similar bug found with dead eventlet runloop. a greenthread doesn't get its parent set to new hub greenlet unless switching back to the hub. If it dies before then it'll return execution to dead hub greenlet.
import eventlet
def dummyproc():
print 'dummyproc returning. but our parent is *old, dead* hub greenlet'
eventlet.sleep(0) # give hub a chance to run
g = eventlet.spawn(dummyproc)
print 'killing hub before spawned greenthread timer is run'
try:
# use throw() method on greenlet rather
# than eventlet.greenthread.kill()
eventlet.hubs.get_hub().greenlet.throw(KeyboardInterrupt())
except KeyboardInterrupt:
pass
print 'killed hub. switching back to create new runloop greenlet'
eventlet.hubs.get_hub().switch()
print 'should not get here!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment