summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/thirdparty/statemachine.py13
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py5
2 files changed, 5 insertions, 13 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):
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index b14ed5eb..145383c1 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -1234,9 +1234,8 @@ class XMLStream(object):
# be resent and processing will resume.
while not self.stop.is_set():
# Only process the stream while connected to the server
- if not self.state.ensure('connected', wait=0.1,
- block_on_transition=True):
- continue
+ if not self.state.ensure('connected', wait=0.1):
+ break
# Ensure the stream header is sent for any
# new connections.
if not self.session_started_event.is_set():