From cc6d5b9a582e6a1cc3686e04a81e0266ae6edc09 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Mon, 13 Apr 2020 14:32:02 +0200 Subject: [PATCH] Set event loop policy on Windows with Python 3.8+. --- daphne/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/daphne/__init__.py b/daphne/__init__.py index 54499df..ca3f13e 100755 --- a/daphne/__init__.py +++ b/daphne/__init__.py @@ -1 +1,14 @@ +import sys + __version__ = "2.4.1" + + +# Windows on Python 3.8+ uses ProactorEventLoop, which is not compatible with +# Twisted. Does not implement add_writer/add_reader. +# See https://bugs.python.org/issue37373 +# and https://twistedmatrix.com/trac/ticket/9766 +PY38_WIN = sys.version_info >= (3, 8) and sys.platform == "win32" +if PY38_WIN: + import asyncio + + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())