diff options
author | Lance Stout <lancestout@gmail.com> | 2012-04-06 17:39:51 -0400 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-04-06 17:39:51 -0400 |
commit | aedbecd6735f6075f871412817f97639bf1365ec (patch) | |
tree | 51624afc3df44c4015d02fe86e6328cd1634a529 /sleekxmpp/thirdparty/statemachine.py | |
parent | 83c5a4cd2fd70c250dfb7e566dad7084d99025a6 (diff) | |
download | slixmpp-aedbecd6735f6075f871412817f97639bf1365ec.tar.gz slixmpp-aedbecd6735f6075f871412817f97639bf1365ec.tar.bz2 slixmpp-aedbecd6735f6075f871412817f97639bf1365ec.tar.xz slixmpp-aedbecd6735f6075f871412817f97639bf1365ec.zip |
Correct the statemachine's ensure_any method.
It had not been updated to use the new condition instead of the old
threading event.
Diffstat (limited to 'sleekxmpp/thirdparty/statemachine.py')
-rw-r--r-- | sleekxmpp/thirdparty/statemachine.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/sleekxmpp/thirdparty/statemachine.py b/sleekxmpp/thirdparty/statemachine.py index df3412d3..33d9b828 100644 --- a/sleekxmpp/thirdparty/statemachine.py +++ b/sleekxmpp/thirdparty/statemachine.py @@ -188,16 +188,7 @@ class StateMachine(object): # avoid an operation occurring in the wrong state. # TODO another option would be an ensure_ctx that uses a semaphore to allow # threads to indicate they want to remain in a particular state. - - # will return immediately if no transition is in process. - if block_on_transition: - # we're not in the middle of a transition; don't hold the lock - if self.lock.acquire(False): - self.lock.release() - # wait for the transition to complete - else: - self.lock.wait() - + self.lock.acquire() start = time.time() while not self.__current_state in states: # detect timeout: @@ -205,7 +196,9 @@ class StateMachine(object): if remainder > 0: self.lock.wait(remainder) else: + self.lock.release() return False + self.lock.release() return True def reset(self): |