Merge pull request #328 from FlySnake/develop
On initial connect use delay if connection failed
This commit is contained in:
commit
1e77ea0944
1 changed files with 4 additions and 2 deletions
|
@ -460,9 +460,11 @@ class XMLStream(object):
|
||||||
def _connect(self, reattempt=True):
|
def _connect(self, reattempt=True):
|
||||||
self.scheduler.remove('Session timeout check')
|
self.scheduler.remove('Session timeout check')
|
||||||
|
|
||||||
if self.reconnect_delay is None or not reattempt:
|
if self.reconnect_delay is None:
|
||||||
delay = 1.0
|
delay = 1.0
|
||||||
else:
|
self.reconnect_delay = delay
|
||||||
|
|
||||||
|
if reattempt:
|
||||||
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)
|
||||||
|
|
Loading…
Reference in a new issue