From fba60ffff11d42f2e6edecdfcb4200a50a844bed Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sun, 20 Nov 2011 12:15:39 -0800 Subject: 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. --- sleekxmpp/xmlstream/handler/waiter.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'sleekxmpp/xmlstream/handler') 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 -- cgit v1.2.3