Tools
- delay
From: http://fredericiana.com/2014/11/14/settimeout-python-delay/
import threading
from functools import wraps
def delay(delay=0.):
"""
Decorator delaying the execution of a function for a while.
"""
def wrap(f):
@wraps(f)
def delayed(*args, **kwargs):
timer = threading.Timer(delay, f, args=args, kwargs=kwargs)
timer.start()
return delayed
return wrap
@delay(3.0)
def my_func(arg1, arg2):
print arg1, arg2
if __name__ == '__main__':
my_func('Hello', 'world')