Mercurial > libervia-web
changeset 846:c1907a460f6a
browser (json): changed rules for retry delay when connection with server is lost
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 15 Jan 2016 15:42:37 +0100 |
parents | a5b5178ef6b9 |
children | 330db23d4a44 |
files | src/browser/sat_browser/json.py |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/browser/sat_browser/json.py Fri Jan 15 15:42:37 2016 +0100 +++ b/src/browser/sat_browser/json.py Fri Jan 15 15:42:37 2016 +0100 @@ -30,6 +30,7 @@ from sat_browser import main_panel from sat_browser.constants import Const as C +import random class LiberviaMethodProxy(object): @@ -248,9 +249,14 @@ msg_html = u"Connection with server lost. Retrying in <strong>{}</strong> s".format(remaining) self.retry_warning.showWarning("WARNING", msg_html, None) - retry_delay = 2**self.retry_nb + if self.retry_nb < 3: + retry_delay = 1 + elif self.retry_nb < 10: + retry_delay = random.randint(1,10) + else: + retry_delay = random.randint(1,60) self.retry_nb += 1 - log.warning(u"Lost connection, trying to reconnect in {} s".format(retry_delay)) + log.warning(u"Lost connection, trying to reconnect in {} s (try #{})".format(retry_delay, self.retry_nb)) self.retry_time = time.time() + retry_delay self.retry_warning = main_panel.WarningPopup() self.retry_timer = Timer(notify=_timerCb)