Skip to content

Instantly share code, notes, and snippets.

@nom3ad
Created December 6, 2016 06:26
Show Gist options
  • Save nom3ad/c80a2c2f9dee6bfaf3b8f691696405e2 to your computer and use it in GitHub Desktop.
Save nom3ad/c80a2c2f9dee6bfaf3b8f691696405e2 to your computer and use it in GitHub Desktop.
import threading
def spawnthread(f):
def func(*args,**kwargs):
thr = threading.Thread(target=f, args=args, kwargs=kwargs)
thr.start()
return func
# --------------------------
import time
@spawnthread
def x(a):
print 'start',a
time.sleep(5)
print 'end',a
x(10);x(20);x(30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment