Prevent hang when terminating during delayed connection.

This commit is contained in:
Lance Stout 2011-12-07 22:16:58 -08:00
parent a720c3348b
commit 2a67a31120

View file

@ -398,7 +398,16 @@ class XMLStream(object):
delay = min(self.reconnect_delay * 2, self.reconnect_max_delay) delay = min(self.reconnect_delay * 2, self.reconnect_max_delay)
delay = random.normalvariate(delay, delay * 0.1) delay = random.normalvariate(delay, delay * 0.1)
log.debug('Waiting %s seconds before connecting.', delay) 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: if self.use_proxy:
connected = self._connect_proxy() connected = self._connect_proxy()