Created
June 10, 2014 00:01
-
-
Save harlowja/9c35e443dfa136a4f965 to your computer and use it in GitHub Desktop.
Lock 'er up
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 eventlet | |
eventlet.monkey_patch(os=False, thread=False) | |
import time | |
import threading | |
LOCK = threading.Lock() | |
def do_things(a): | |
with LOCK: | |
print("Doing thing %s" % a) | |
time.sleep(1) | |
count = 5 | |
threads = [] | |
for i in range(0, 5): | |
threads.append(eventlet.spawn(do_things, [i])) | |
while threads: | |
t = threads.pop() | |
t.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment