Last active
December 21, 2015 13:09
-
-
Save stestagg/6311039 to your computer and use it in GitHub Desktop.
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
cdef extern from "unistd.h": | |
cdef void sleep(int time) | |
def lock(time): | |
print "starting to block" | |
sleep(10) | |
print "stop blocking" | |
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 pyximport; pyximport.install() | |
import time | |
import gil | |
import threading | |
class Test(threading.Thread): | |
def run(self): | |
num = 0 | |
while True: | |
print num | |
num += 1 | |
def main(): | |
tt = Test() | |
tt.daemon = True | |
tt.start() | |
time.sleep(0.1) | |
gil.lock(4) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment