forked from platypush/platypush
More robust websocket retry handler for Todoist
This commit is contained in:
parent
d27b23ec5a
commit
2ceb3511b3
1 changed files with 14 additions and 9 deletions
|
@ -58,15 +58,7 @@ class TodoistBackend(Backend):
|
||||||
|
|
||||||
return hndl
|
return hndl
|
||||||
|
|
||||||
def _on_error(self):
|
def _retry_hndl(self):
|
||||||
# noinspection PyUnusedLocal
|
|
||||||
def hndl(ws, error):
|
|
||||||
self.logger.warning('Todoist websocket error: {}'.format(error))
|
|
||||||
return hndl
|
|
||||||
|
|
||||||
def _on_close(self):
|
|
||||||
# noinspection PyUnusedLocal
|
|
||||||
def hndl(ws):
|
|
||||||
self._ws = None
|
self._ws = None
|
||||||
self.logger.warning('Todoist websocket connection closed')
|
self.logger.warning('Todoist websocket connection closed')
|
||||||
self._connected = False
|
self._connected = False
|
||||||
|
@ -75,6 +67,19 @@ class TodoistBackend(Backend):
|
||||||
self._connect()
|
self._connect()
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
|
def _on_error(self):
|
||||||
|
# noinspection PyUnusedLocal
|
||||||
|
def hndl(ws, error):
|
||||||
|
self.logger.warning('Todoist websocket error: {}'.format(error))
|
||||||
|
self._retry_hndl()
|
||||||
|
|
||||||
|
return hndl
|
||||||
|
|
||||||
|
def _on_close(self):
|
||||||
|
def hndl(*_, **__):
|
||||||
|
self.logger.info('Todoist websocket closed')
|
||||||
|
self._retry_hndl()
|
||||||
|
|
||||||
return hndl
|
return hndl
|
||||||
|
|
||||||
def _on_open(self):
|
def _on_open(self):
|
||||||
|
|
Loading…
Reference in a new issue