reconnect is now launched in a thread
This commit is contained in:
parent
676b7600cf
commit
25dfa506cd
|
@ -422,7 +422,14 @@ class Connection:
|
||||||
# END disconenctedCB
|
# END disconenctedCB
|
||||||
|
|
||||||
def _reconnect(self):
|
def _reconnect(self):
|
||||||
|
# Do not try to reco while we are already trying
|
||||||
|
self.time_to_reconnect = None
|
||||||
|
t = threading.Thread(target=self._reconnect2)
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
def _reconnect2(self):
|
||||||
gajim.log.debug('reconnect')
|
gajim.log.debug('reconnect')
|
||||||
|
self.retrycount += 1
|
||||||
signed = self.get_signed_msg(self.status)
|
signed = self.get_signed_msg(self.status)
|
||||||
self.connect_and_init(self.old_show, self.status, signed)
|
self.connect_and_init(self.old_show, self.status, signed)
|
||||||
if self.connected < 2: #connection failed
|
if self.connected < 2: #connection failed
|
||||||
|
@ -432,10 +439,8 @@ class Connection:
|
||||||
self.dispatch('ERROR',
|
self.dispatch('ERROR',
|
||||||
(_('Connection with account "%s" has been lost') % self.name,
|
(_('Connection with account "%s" has been lost') % self.name,
|
||||||
_('To continue sending and receiving messages, you will need to reconnect.')))
|
_('To continue sending and receiving messages, you will need to reconnect.')))
|
||||||
self.time_to_reconnect = None
|
|
||||||
self.retrycount = 0
|
self.retrycount = 0
|
||||||
return
|
return
|
||||||
self.retrycount = self.retrycount + 1
|
|
||||||
if self.retrycount > 5:
|
if self.retrycount > 5:
|
||||||
self.time_to_reconnect = time.time() + 20
|
self.time_to_reconnect = time.time() + 20
|
||||||
else:
|
else:
|
||||||
|
@ -1325,7 +1330,7 @@ class Connection:
|
||||||
con_type = con.connect((h, p), proxy = proxy, secure=secur) #FIXME: blocking
|
con_type = con.connect((h, p), proxy = proxy, secure=secur) #FIXME: blocking
|
||||||
if not con_type:
|
if not con_type:
|
||||||
gajim.log.debug("Couldn't connect to %s" % self.name)
|
gajim.log.debug("Couldn't connect to %s" % self.name)
|
||||||
if not self.time_to_reconnect:
|
if not self.retrycount:
|
||||||
self.connected = 0
|
self.connected = 0
|
||||||
self.dispatch('STATUS', 'offline')
|
self.dispatch('STATUS', 'offline')
|
||||||
self.dispatch('ERROR', (_('Could not connect to "%s"') % self.name,
|
self.dispatch('ERROR', (_('Could not connect to "%s"') % self.name,
|
||||||
|
|
Loading…
Reference in New Issue