From 343090704641c2380d98bdb1e068574e466cc186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=BD=E9=A3=8E?= Date: Sat, 4 Jan 2020 12:20:42 +0800 Subject: [PATCH] fix 1748 : Drop DeprecationWarning in python 3.8 (#1750) https://github.com/huge-success/sanic/issues/1748 --- sanic/server.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sanic/server.py b/sanic/server.py index 2e6be4a5..47ebcd95 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -1,5 +1,6 @@ import asyncio import os +import sys import traceback from collections import deque @@ -134,7 +135,10 @@ class HttpProtocol(asyncio.Protocol): self.request_class = request_class or Request self.is_request_stream = is_request_stream self._is_stream_handler = False - self._not_paused = asyncio.Event(loop=loop) + if sys.version_info.minor >= 8: + self._not_paused = asyncio.Event() + else: + self._not_paused = asyncio.Event(loop=loop) self._total_request_size = 0 self._request_timeout_handler = None self._response_timeout_handler = None @@ -951,7 +955,10 @@ def serve( else: conn.close() - _shutdown = asyncio.gather(*coros, loop=loop) + if sys.version_info.minor >= 8: + _shutdown = asyncio.gather(*coros, loop=loop) + else: + _shutdown = asyncio.gather(*coros) loop.run_until_complete(_shutdown) trigger_events(after_stop, loop)