diff options
Diffstat (limited to 'pypers/oxford/deferred.py')
-rwxr-xr-x | pypers/oxford/deferred.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/pypers/oxford/deferred.py b/pypers/oxford/deferred.py new file mode 100755 index 0000000..653421e --- /dev/null +++ b/pypers/oxford/deferred.py @@ -0,0 +1,21 @@ +# deferred.py
+"Deferring the execution of a procedure (function returning None)"
+
+import threading
+from decorators import decorator
+
+def deferred(nsec):
+ def call_later(func, *args, **kw):
+ return threading.Timer(nsec, func, args, kw).start()
+ return decorator(call_later)
+
+@deferred(2)
+def hello():
+ print "hello"
+
+if __name__ == "__main__":
+ hello()
+ print "Calling hello() ..."
+
+
+
|