summaryrefslogtreecommitdiff
path: root/sleekxmpp
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-12-07 22:16:58 -0800
committerLance Stout <lancestout@gmail.com>2011-12-07 22:16:58 -0800
commit2a67a31120ade3664cc3bf49e04367ca27caf21f (patch)
tree787753c02705e711ec7619a3bcd3189d09387f78 /sleekxmpp
parenta720c3348b3d5b4156dc5c741ee25410a2af5af0 (diff)
downloadslixmpp-2a67a31120ade3664cc3bf49e04367ca27caf21f.tar.gz
slixmpp-2a67a31120ade3664cc3bf49e04367ca27caf21f.tar.bz2
slixmpp-2a67a31120ade3664cc3bf49e04367ca27caf21f.tar.xz
slixmpp-2a67a31120ade3664cc3bf49e04367ca27caf21f.zip
Prevent hang when terminating during delayed connection.
Diffstat (limited to 'sleekxmpp')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 8fcf2b5f..1a0b6241 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -398,7 +398,16 @@ class XMLStream(object):
delay = min(self.reconnect_delay * 2, self.reconnect_max_delay)
delay = random.normalvariate(delay, delay * 0.1)
log.debug('Waiting %s seconds before connecting.', delay)
- time.sleep(delay)
+ elapsed = 0
+ try:
+ while elapsed < delay and not self.stop.is_set():
+ time.sleep(0.1)
+ except KeyboardInterrupt:
+ self.stop.set()
+ return False
+ except SystemExit:
+ self.stop.set()
+ return False
if self.use_proxy:
connected = self._connect_proxy()