Skip to content

Instantly share code, notes, and snippets.

@vzts
Last active December 23, 2019 06:58
Show Gist options
  • Save vzts/a647b41d8a2e25d834c7309729a47624 to your computer and use it in GitHub Desktop.
Save vzts/a647b41d8a2e25d834c7309729a47624 to your computer and use it in GitHub Desktop.
time.sleep gevent.sleep test
import threading
import time
import gevent
def hi1():
time.sleep(3) # release GIL
print('hi1')
def hi2():
def hi3():
gevent.sleep(1)
print('hi3')
gevent.spawn(hi3)
gevent.sleep(5) # should not release GIL?
print('hi2')
threading.Thread(target=hi1).start()
threading.Thread(target=hi2).start()
# prints:
# hi3
# hi1 <-- should it print?
# hi2
# gevent: 1.4.0
# python: 2.7, 3.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment