From bc8d2d31538dcd048e6c39b5bd64709ec876d128 Mon Sep 17 00:00:00 2001 From: Espy | Neko | 404 <34942042+neko404notfound@users.noreply.github.com> Date: Wed, 23 May 2018 18:34:54 +0100 Subject: [PATCH] Update __main__.py --- src/__main__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/__main__.py b/src/__main__.py index e6b15ea..964d74e 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -11,6 +11,7 @@ import logging import random import traceback import os +import sys import discord from discord.ext import commands @@ -27,9 +28,15 @@ logging.basicConfig(level='INFO') # If uvloop is installed, change to that eventloop policy as it # is more efficient try: - import uvloop - asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) - del uvloop + # https://stackoverflow.com/a/45700730 + if sys.platform == 'win32': + loop = asyncio.ProactorEventLoop() + asyncio.set_event_loop(loop) + logging.warning('Detected Windows. Changing event loop to ProactorEventLoop.') + else: + import uvloop + asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) + del uvloop except BaseException as ex: logging.warning(f'Could not load uvloop. {type(ex).__qualname__}: {ex};', 'reverting to default impl.')