Skip to content

Instantly share code, notes, and snippets.

@edwardgeorge
Created August 11, 2012 09:46
Show Gist options
  • Save edwardgeorge/3323182 to your computer and use it in GitHub Desktop.
Save edwardgeorge/3323182 to your computer and use it in GitHub Desktop.
demonstrates a subtle eventlet bug when killing greenthreads after the runloop dies but hasn't been restarted by a switch().
import eventlet
ev = eventlet.event.Event()
def dummyproc():
eventlet.hubs.get_hub().switch()
g = eventlet.spawn(dummyproc)
print 'Feel free to terminate with ctrl-C'
try:
eventlet.hubs.get_hub().switch()
except KeyboardInterrupt:
print ('Runloop died, terminating greenthread.'
' This schedules a timer to switch back to this greenthread after'
' exception is thrown in greenthread.')
g.kill()
print 'Should now wait forever on event.'
ev.wait()
print 'Ooops! We\'ve been rescheduled by timer set by kill above.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment