Skip to content

Instantly share code, notes, and snippets.

@pcote
Created July 21, 2015 22:40
Show Gist options
  • Save pcote/fffcc396be0466e21818 to your computer and use it in GitHub Desktop.
Save pcote/fffcc396be0466e21818 to your computer and use it in GitHub Desktop.
from threading import Thread
from random import random, seed
from time import time, sleep
from functools import wraps
def concurrent(func):
@wraps(func)
def wrapper(*args, **kwargs):
Thread(target=func, args=args).start()
return wrapper
@concurrent
def argue(sentence):
seed(time())
for word in sentence.split():
sleep(random())
print(word)
if __name__ == '__main__':
argue("Python is terrible because of significant whitespace.")
argue("Oh yeah, well Java is worse because it's verbose")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment