From a7412d1c879920c3b2c2871763aafbe6836d1ed7 Mon Sep 17 00:00:00 2001 From: ziajka Date: Thu, 26 Oct 2017 16:29:01 +0200 Subject: [PATCH 1/2] aiohttp 2.3.1 dependency --- gns3server/controller/compute.py | 8 +++++++- gns3server/web/web_server.py | 11 ++++++++--- requirements.txt | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index 05154fd3..8a3d35e8 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -506,10 +506,16 @@ class Compute: else: data = json.dumps(data).encode("utf-8") try: + log.debug("Attempting request to compute: {method} {url} {headers}".format( + method=method, + url=url, + headers=headers + )) response = yield from self._session().request(method, url, headers=headers, data=data, auth=self._auth, chunked=chunked, timeout=timeout) except asyncio.TimeoutError as e: raise ComputeError("Timeout error when connecting to {}".format(url)) - except (aiohttp.ClientError, aiohttp.ServerDisconnectedError, ValueError, KeyError) as e: + except (aiohttp.ClientError, aiohttp.ServerDisconnectedError, ValueError, KeyError, socket.gaierror) as e: + # aiohttp 2.3.1 raises socket.gaierror when cannot find host raise ComputeError(str(e)) body = yield from response.read() if body and not raw: diff --git a/gns3server/web/web_server.py b/gns3server/web/web_server.py index 40179367..9ce9c2e0 100644 --- a/gns3server/web/web_server.py +++ b/gns3server/web/web_server.py @@ -43,8 +43,8 @@ import gns3server.handlers import logging log = logging.getLogger(__name__) -if not aiohttp.__version__.startswith("2.2"): - raise RuntimeError("aiohttp 2.2 is required to run the GNS3 server") +if not (aiohttp.__version__.startswith("2.2") or aiohttp.__version__.startswith("2.3")): + raise RuntimeError("aiohttp 2.2.x or 2.3.x is required to run the GNS3 server") class WebServer: @@ -102,7 +102,12 @@ class WebServer: if self._app: yield from self._app.shutdown() if self._handler: - yield from self._handler.finish_connections(2) # Parameter is timeout + try: + # aiohttp < 2.3 + yield from self._handler.finish_connections(2) # Parameter is timeout + except AttributeError: + # aiohttp >= 2.3 + yield from self._handler.shutdown(2) # Parameter is timeout if self._app: yield from self._app.cleanup() diff --git a/requirements.txt b/requirements.txt index 2d882257..fb75fc6d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ jsonschema>=2.4.0 -aiohttp>=2.2.0,<2.3.0 # pyup: ignore +aiohttp>=2.3.0,<2.4.0 # pyup: ignore aiohttp-cors>=0.5.3,<0.6.0 # pyup: ignore yarl>=0.11,<0.12 # pyup: ignore Jinja2>=2.7.3 From 2235a8158fbf74d6ef5c01a4785e110f73457491 Mon Sep 17 00:00:00 2001 From: ziajka Date: Wed, 15 Nov 2017 09:00:14 +0100 Subject: [PATCH 2/2] Update requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fb75fc6d..b81fe029 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ jsonschema>=2.4.0 -aiohttp>=2.3.0,<2.4.0 # pyup: ignore +aiohttp>=2.2.0,<2.4.0 # pyup: ignore aiohttp-cors>=0.5.3,<0.6.0 # pyup: ignore yarl>=0.11,<0.12 # pyup: ignore Jinja2>=2.7.3