git » pymisc » commit 64beac8

Fix dataflow decorator by moving the wrapper generation inside the call.

author Alberto Bertogli
2006-09-26 06:06:23 UTC
committer Alberto Bertogli
2006-09-26 06:06:23 UTC
parent 5eb37cd1afbc910dae925e7eb211a2b6043625d4

Fix dataflow decorator by moving the wrapper generation inside the call.

dataflow.py +4 -4

diff --git a/dataflow.py b/dataflow.py
index 875e94f..ac09d40 100644
--- a/dataflow.py
+++ b/dataflow.py
@@ -75,8 +75,7 @@ class _DFWrapper:
 
 def dataflow(f):
 	"Dataflow decorator"
-	obj = _DFWrapper()
-	def threadedf(*args, **kwargs):
+	def threadedf(obj, *args, **kwargs):
 		v = f(*args, **kwargs)
 		obj._override = True
 		olock = obj._lock
@@ -89,8 +88,9 @@ def dataflow(f):
 		olock.release()
 
 	def newf(*args, **kwargs):
-		thread.start_new_thread(threadedf, args, kwargs)
-		return obj
+		o = _DFWrapper()
+		thread.start_new_thread(threadedf, (o,) + args, kwargs)
+		return o
 
 	return newf