Skip to content

Instantly share code, notes, and snippets.

@harlowja
Created June 10, 2014 00:01
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 harlowja/9c35e443dfa136a4f965 to your computer and use it in GitHub Desktop.
Save harlowja/9c35e443dfa136a4f965 to your computer and use it in GitHub Desktop.
Lock 'er up
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