diff --git a/httpstan/main.py b/httpstan/main.py index 3417a5730..674672143 100644 --- a/httpstan/main.py +++ b/httpstan/main.py @@ -8,7 +8,11 @@ from typing import Optional import aiohttp.web -import uvloop + +try: + from uvloop import EventLoopPolicy +except ImportError: + EventLoopPolicy = asyncio.DefaultEventLoopPolicy import httpstan.routes @@ -59,7 +63,7 @@ class Server(threading.Thread): def __init__(self, host: str = "127.0.0.1", port: Optional[int] = None) -> None: super().__init__() self.host, self.port = host, port - asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) + asyncio.set_event_loop_policy(EventLoopPolicy()) self.loop = asyncio.new_event_loop() # control will be passed to thread self.app = make_app() self.runner = aiohttp.web.AppRunner(self.app) diff --git a/requirements.txt b/requirements.txt index a133e10fb..dd899a56f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,4 @@ apispec<1,>=0.21 protobuf<4,>=3.3.0 setuptools>=28.8 ujson<2,>=1.3 -uvloop<1,>=0.11.2 +uvloop<1,>=0.11.2; sys_platform != "win32" or implementation_name == "PyPy"