fix 1748 : Drop DeprecationWarning in python 3.8 (#1750)

https://github.com/huge-success/sanic/issues/1748
This commit is contained in:
好风 2020-01-04 12:20:42 +08:00 committed by 7
parent 2f776eba85
commit 3430907046

View File

@ -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)