From a98fc2d308604ef9aa4b1788c4a7f99f67d8b8cd Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 11 Nov 2019 12:44:31 +0800 Subject: [PATCH] Python3.8 support. Ref https://github.com/GNS3/gns3-gui/issues/2895 --- .travis.yml | 1 + gns3server/handlers/api/compute/project_handler.py | 2 +- gns3server/notification_queue.py | 2 +- gns3server/utils/asyncio/__init__.py | 4 +--- gns3server/web/route.py | 9 +++++---- setup.py | 1 + 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index eb9ef803..0e439c97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,3 +30,4 @@ env: - PYTHON_VERSION=3.5 - PYTHON_VERSION=3.6 - PYTHON_VERSION=3.7 + - PYTHON_VERSION=3.8 diff --git a/gns3server/handlers/api/compute/project_handler.py b/gns3server/handlers/api/compute/project_handler.py index e59d9ab5..ddca533c 100644 --- a/gns3server/handlers/api/compute/project_handler.py +++ b/gns3server/handlers/api/compute/project_handler.py @@ -193,7 +193,7 @@ class ProjectHandler: msg = json.dumps({"action": action, "event": msg}, sort_keys=True) log.debug("Send notification: %s", msg) await response.write(("{}\n".format(msg)).encode("utf-8")) - except asyncio.futures.TimeoutError: + except asyncio.TimeoutError: await response.write("{}\n".format(json.dumps(ProjectHandler._getPingMessage())).encode("utf-8")) project.stop_listen_queue(queue) if project.id in ProjectHandler._notifications_listening: diff --git a/gns3server/notification_queue.py b/gns3server/notification_queue.py index 889e49b9..6a022eec 100644 --- a/gns3server/notification_queue.py +++ b/gns3server/notification_queue.py @@ -42,7 +42,7 @@ class NotificationQueue(asyncio.Queue): try: (action, msg, kwargs) = await asyncio.wait_for(super().get(), timeout) - except asyncio.futures.TimeoutError: + except asyncio.TimeoutError: return ("ping", PingStats.get(), {}) return (action, msg, kwargs) diff --git a/gns3server/utils/asyncio/__init__.py b/gns3server/utils/asyncio/__init__.py index ea0dc363..515f2d85 100644 --- a/gns3server/utils/asyncio/__init__.py +++ b/gns3server/utils/asyncio/__init__.py @@ -22,8 +22,6 @@ import sys import os import threading -from asyncio.futures import CancelledError - async def wait_run_in_executor(func, *args, **kwargs): """ @@ -56,7 +54,7 @@ async def cancellable_wait_run_in_executor(func, *args, **kwargs): kwargs['stopped_event'] = stopped_event try: await wait_run_in_executor(func, *args, **kwargs) - except CancelledError: + except asyncio.CancelledError: stopped_event.set() diff --git a/gns3server/web/route.py b/gns3server/web/route.py index e656d45b..8efd1bf6 100644 --- a/gns3server/web/route.py +++ b/gns3server/web/route.py @@ -20,13 +20,10 @@ import json import urllib import asyncio import aiohttp -import logging import traceback import jsonschema import jsonschema.exceptions -log = logging.getLogger(__name__) - from ..compute.error import NodeError, ImageMissingError from ..controller.controller_error import ControllerError from ..ubridge.ubridge_error import UbridgeError @@ -36,6 +33,10 @@ from ..crash_report import CrashReport from ..config import Config +import logging +log = logging.getLogger(__name__) + + async def parse_request(request, input_schema, raw): """Parse body of request and raise HTTP errors in case of problems""" @@ -217,7 +218,7 @@ class Route(object): response = Response(request=request, route=route) response.set_status(409) response.json({"message": str(e), "status": 409, "image": e.image, "exception": e.__class__.__name__}) - except asyncio.futures.CancelledError: + except asyncio.CancelledError: response = Response(request=request, route=route) response.set_status(408) response.json({"message": "Request canceled", "status": 408}) diff --git a/setup.py b/setup.py index f6bb40db..0d523004 100644 --- a/setup.py +++ b/setup.py @@ -77,6 +77,7 @@ setup( "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", ], )