Last active
December 23, 2019 06:58
-
-
Save vzts/a647b41d8a2e25d834c7309729a47624 to your computer and use it in GitHub Desktop.
time.sleep gevent.sleep test
This file contains 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 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