Skip to content

Instantly share code, notes, and snippets.

@notmyname
Created June 18, 2015 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notmyname/0004945577d4b3cd2855 to your computer and use it in GitHub Desktop.
Save notmyname/0004945577d4b3cd2855 to your computer and use it in GitHub Desktop.
from eventlet import greenthread
from eventlet import sleep, Timeout
import time
def foo():
sleep(10)
start = time.time()
gt = greenthread.spawn(foo)
try:
with Timeout(2):
gt.wait()
except:
pass
end = time.time()
print end - start, 'seconds'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment