Skip to content
Snippets Groups Projects
Commit f753a9fe authored by Anael Beutot's avatar Anael Beutot
Browse files

Reconnects RPC after a 1 seconds delay.

parent 3fc6b7e9
No related branches found
No related tags found
No related merge requests found
...@@ -206,6 +206,7 @@ class MainLoop(object): ...@@ -206,6 +206,7 @@ class MainLoop(object):
self.rpc_con = None self.rpc_con = None
self.connect = RPCStartHandler(self) self.connect = RPCStartHandler(self)
self.reconnect = None
# role # role
self.role = None self.role = None
...@@ -296,11 +297,19 @@ class MainLoop(object): ...@@ -296,11 +297,19 @@ class MainLoop(object):
logger.error('Lost connection to the cc-server, will attempt' logger.error('Lost connection to the cc-server, will attempt'
' reconnection') ' reconnection')
# reconnection atempt in one second
self.reconnect = self.evloop.timer(
1.,0., self.restart_rpc_connection_cb)
self.reconnect.start()
def restart_rpc_connection_cb(self, *args):
# clear connection # clear connection
self.rpc_con = None self.rpc_con = None
# attempt to connect to the cc-server again # attempt to connect to the cc-server again
self.connect = RPCStartHandler(self) self.connect = RPCStartHandler(self)
self.connect.start() self.connect.start()
self.reconnect.stop()
self.reconnect = None
def start(self): def start(self):
logger.info('Starting node') logger.info('Starting node')
...@@ -315,6 +324,8 @@ class MainLoop(object): ...@@ -315,6 +324,8 @@ class MainLoop(object):
logger.info('Exiting node...') logger.info('Exiting node...')
if self.connect is not None: if self.connect is not None:
self.connect.stop() self.connect.stop()
if self.reconnect is not None:
self.reconnect.stop()
# close rpc # close rpc
if self.rpc_con is not None: if self.rpc_con is not None:
# disable callback to prevent trampoline calls # disable callback to prevent trampoline calls
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment