diff options
author | Lance Stout <lancestout@gmail.com> | 2012-08-10 14:11:44 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-08-10 14:11:44 -0700 |
commit | 814a50e36feb73ced9152680560261addf3ff0ea (patch) | |
tree | 6e610189cd34f52fd76cf88aeb816c421d474ba8 /sleekxmpp | |
parent | 230465b94637ff83cd40e8a2a2fe117d61d5fe79 (diff) | |
download | slixmpp-814a50e36feb73ced9152680560261addf3ff0ea.tar.gz slixmpp-814a50e36feb73ced9152680560261addf3ff0ea.tar.bz2 slixmpp-814a50e36feb73ced9152680560261addf3ff0ea.tar.xz slixmpp-814a50e36feb73ced9152680560261addf3ff0ea.zip |
Fix handling state machine lock when quick exiting.
Diffstat (limited to 'sleekxmpp')
-rw-r--r-- | sleekxmpp/thirdparty/statemachine.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sleekxmpp/thirdparty/statemachine.py b/sleekxmpp/thirdparty/statemachine.py index 1f01a92a..4b5ecd6b 100644 --- a/sleekxmpp/thirdparty/statemachine.py +++ b/sleekxmpp/thirdparty/statemachine.py @@ -83,16 +83,16 @@ class StateMachine(object): if not to_state in self.__states: raise ValueError("StateMachine does not contain to_state %s." % to_state) + if self.__current_state == to_state: + return True + start = time.time() while not self.lock.acquire(False): time.sleep(.001) if (start + wait - time.time()) <= 0.0: - log.debug("Could not acquire lock") + log.debug("==== Could not acquire lock in %s sec: %s -> %s ", wait, self.__current_state, to_state) return False - if self.__current_state == to_state: - return True - while not self.__current_state in from_states: # detect timeout: remainder = start + wait - time.time() |