Created
August 11, 2012 09:46
-
-
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().
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
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