summaryrefslogtreecommitdiff
path: root/sleekxmpp/thirdparty/statemachine.py
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp/thirdparty/statemachine.py')
-rw-r--r--sleekxmpp/thirdparty/statemachine.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/sleekxmpp/thirdparty/statemachine.py b/sleekxmpp/thirdparty/statemachine.py
index 60ba792f..54070db1 100644
--- a/sleekxmpp/thirdparty/statemachine.py
+++ b/sleekxmpp/thirdparty/statemachine.py
@@ -82,18 +82,22 @@ class StateMachine(object):
if not to_state in self.__states:
raise ValueError( "StateMachine does not contain to_state %s." % to_state )
-
start = time.time()
while not self.lock.acquire(False):
time.sleep(.001)
if (start + wait - time.time()) <= 0.0:
+ logging.debug("Could not acquire lock")
return False
while not self.__current_state in from_states:
# detect timeout:
remainder = start + wait - time.time()
- if remainder > 0: self.notifier.wait(remainder)
- else: return False
+ if remainder > 0:
+ self.notifier.wait(remainder)
+ else:
+ logging.debug("State was not ready")
+ self.lock.release()
+ return False
try: # lock is acquired; all other threads will return false or wait until notify/timeout
if self.__current_state in from_states: # should always be True due to lock