1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Fix stacktrace display when connecting to remote server

Fix #891
This commit is contained in:
Julien Duponchelle 2017-02-06 17:56:08 +01:00
parent 6ded234681
commit 94fd4bcbe9
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8

View File

@ -361,6 +361,16 @@ class Compute:
response = yield from self._run_http_query(method, path, data=data, **kwargs) response = yield from self._run_http_query(method, path, data=data, **kwargs)
return response return response
@asyncio.coroutine
def _try_reconnect(self):
"""
We catch error during reconnect
"""
try:
yield from self.connect()
except aiohttp.web.HTTPConflict:
pass
@locked_coroutine @locked_coroutine
def connect(self): def connect(self):
""" """
@ -375,8 +385,10 @@ class Compute:
self._connection_failure += 1 self._connection_failure += 1
# After 5 failure we close the project using the compute to avoid sync issues # After 5 failure we close the project using the compute to avoid sync issues
if self._connection_failure == 5: if self._connection_failure == 5:
log.warning("Can't connect to compute %s", self._id)
yield from self._controller.close_compute_projects(self) yield from self._controller.close_compute_projects(self)
asyncio.get_event_loop().call_later(2, lambda: asyncio.async(self.connect()))
asyncio.get_event_loop().call_later(2, lambda: asyncio.async(self._try_reconnect()))
return return
except aiohttp.web.HTTPNotFound: except aiohttp.web.HTTPNotFound: