[pypy-svn] r24165 - pypy/dist/pypy/lib/logic/computation_space
ludal at codespeak.net
ludal at codespeak.net
Thu Mar 9 11:50:50 CET 2006
Author: ludal
Date: Thu Mar 9 11:50:48 2006
New Revision: 24165
Modified:
pypy/dist/pypy/lib/logic/computation_space/variable.py
Log:
debug deadlock?
Modified: pypy/dist/pypy/lib/logic/computation_space/variable.py
==============================================================================
--- pypy/dist/pypy/lib/logic/computation_space/variable.py (original)
+++ pypy/dist/pypy/lib/logic/computation_space/variable.py Thu Mar 9 11:50:48 2006
@@ -1,4 +1,5 @@
import threading
+import time
#----------- Exceptions ---------------------------------
class VariableException(Exception):
@@ -71,12 +72,31 @@
try:
self._value_condition.acquire()
while not self.is_bound():
- self._value_condition.wait()
+ t1 = time.time()
+ self._value_condition.wait(80)
+ t2 = time.time()
+ if t2-t1>80:
+ raise RuntimeError("possible deadlock??")
return self.val
finally:
self._value_condition.release()
+ def reset(self):
+ self._value_condition.acquire()
+ self._val = NoValue
+ self._value_condition.release()
+
+
+class StreamVar(object):
+ def __init__(self):
+ self.var = SimpleVar()
+
+ def bind( self, val ):
+ newvar = SimpleVar()
+ self.var.bind( (val, newvar) )
+
+
class CsVar(SimpleVar):
"""Dataflow variable linked to a space"""
More information about the Pypy-commit
mailing list