From ae91852cd586c67ddfe10669eed18b3ded332d2f Mon Sep 17 00:00:00 2001 From: Subham Roy Date: Wed, 28 Aug 2019 22:00:23 +0530 Subject: [PATCH] check for already set asyncio event loop policy (#1637) * check for already set asyncio event loop policy * fix linting warning --- sanic/server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sanic/server.py b/sanic/server.py index e1d7a3d22f..0336239502 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -30,7 +30,8 @@ try: import uvloop - asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) + if not isinstance(asyncio.get_event_loop_policy(), uvloop.EventLoopPolicy): + asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) except ImportError: pass