diff options
author | 2020-04-22 13:04:22 -0700 | |
---|---|---|
committer | 2020-04-22 13:04:22 -0700 | |
commit | 6fe18c66c5cb6adcb89a40d33e5ce078331dcc04 (patch) | |
tree | e509750a39f85a8d2fb99134f3ac2929b777aebf | |
parent | Merge pull request #900 from python-discord/fix-category-cache-issue (diff) |
Use selector event loop on Windows
aiodns requires the selector event loop for asyncio. In Python 3.8,
the default event loop for Windows was changed to proactor. To fix this,
the event loop is explicitly set to selector.
-rw-r--r-- | bot/__init__.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/bot/__init__.py b/bot/__init__.py index 2dd4af225..4131b69e9 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -1,3 +1,4 @@ +import asyncio import logging import os import sys @@ -59,3 +60,8 @@ coloredlogs.install(logger=root_log, stream=sys.stdout) logging.getLogger("discord").setLevel(logging.WARNING) logging.getLogger("websockets").setLevel(logging.WARNING) logging.getLogger(__name__) + + +# On Windows, the selector event loop is required for aiodns. +if os.name == "nt": + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) |