mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-23 19:19:53 +00:00
Prevent hang when terminating during delayed connection.
This commit is contained in:
parent
a720c3348b
commit
2a67a31120
1 changed files with 10 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue