summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream/handler/waiter.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-11-20 12:15:39 -0800
committerLance Stout <lancestout@gmail.com>2011-11-20 12:17:35 -0800
commitfba60ffff11d42f2e6edecdfcb4200a50a844bed (patch)
treee3cdc144feaa170323914d8087a850693f02a1b1 /sleekxmpp/xmlstream/handler/waiter.py
parentd1a945a3053b82d2553a48f2d2c5c69664e6fde4 (diff)
downloadslixmpp-fba60ffff11d42f2e6edecdfcb4200a50a844bed.tar.gz
slixmpp-fba60ffff11d42f2e6edecdfcb4200a50a844bed.tar.bz2
slixmpp-fba60ffff11d42f2e6edecdfcb4200a50a844bed.tar.xz
slixmpp-fba60ffff11d42f2e6edecdfcb4200a50a844bed.zip
Convert daemon threads back into normal threads.
This may need to be reverted if CTRL-C handling breaks, but everything works fine so far in testing. Resolves issue #95.
Diffstat (limited to 'sleekxmpp/xmlstream/handler/waiter.py')
-rw-r--r--sleekxmpp/xmlstream/handler/waiter.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/sleekxmpp/xmlstream/handler/waiter.py b/sleekxmpp/xmlstream/handler/waiter.py
index 21fc347c..a64b6a9b 100644
--- a/sleekxmpp/xmlstream/handler/waiter.py
+++ b/sleekxmpp/xmlstream/handler/waiter.py
@@ -87,11 +87,16 @@ class Waiter(BaseHandler):
if timeout is None:
timeout = self.stream().response_timeout
- try:
- stanza = self._payload.get(True, timeout)
- except queue.Empty:
- stanza = False
- log.warning("Timed out waiting for %s", self.name)
+ elapsed_time = 0
+ stanza = False
+ while elapsed_time < timeout and not self.stream().stop.is_set():
+ try:
+ stanza = self._payload.get(True, 1)
+ break
+ except queue.Empty:
+ elapsed_time += 1
+ if elapsed_time >= timeout:
+ log.warning("Timed out waiting for %s", self.name)
self.stream().remove_handler(self.name)
return stanza