From 94fd4bcbe9acc3f3ae82a0bd172f89fab6e088bd Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 6 Feb 2017 17:56:08 +0100 Subject: [PATCH] Fix stacktrace display when connecting to remote server Fix #891 --- gns3server/controller/compute.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index 7437d796..413abba6 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -361,6 +361,16 @@ class Compute: response = yield from self._run_http_query(method, path, data=data, **kwargs) 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 def connect(self): """ @@ -375,8 +385,10 @@ class Compute: self._connection_failure += 1 # After 5 failure we close the project using the compute to avoid sync issues if self._connection_failure == 5: + log.warning("Can't connect to compute %s", self._id) 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 except aiohttp.web.HTTPNotFound: