From 77eab6544f1f44f2450ecca4e7588dd60e484631 Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Wed, 20 Oct 2010 19:18:27 -0700 Subject: reconnect if session isn't established within 15 seconds --- sleekxmpp/thirdparty/statemachine.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'sleekxmpp/thirdparty') 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 -- cgit v1.2.3