summaryrefslogtreecommitdiff
path: root/sleekxmpp/thirdparty
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2010-10-20 19:18:27 -0700
committerNathan Fritz <nathan@andyet.net>2010-10-20 19:18:27 -0700
commit77eab6544f1f44f2450ecca4e7588dd60e484631 (patch)
tree1577381a1e45d75fe43ef16383f902395d1080f8 /sleekxmpp/thirdparty
parent11264fe0a8d1224b9a185fc0439359477ef9c3cc (diff)
downloadslixmpp-77eab6544f1f44f2450ecca4e7588dd60e484631.tar.gz
slixmpp-77eab6544f1f44f2450ecca4e7588dd60e484631.tar.bz2
slixmpp-77eab6544f1f44f2450ecca4e7588dd60e484631.tar.xz
slixmpp-77eab6544f1f44f2450ecca4e7588dd60e484631.zip
reconnect if session isn't established within 15 seconds
Diffstat (limited to 'sleekxmpp/thirdparty')
-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