Skip to content

Commit 73c59c6

Browse files
committed
Support running the bot under Windows
aiodns requires this event loop type on windows, as it does not work on the default loop.
1 parent 3c08548 commit 73c59c6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

bot/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""The main bot module, contains all code for the bot application."""
22

3+
import asyncio
34
import logging
45
import os
56
from pathlib import Path
@@ -30,6 +31,10 @@
3031
console_handler.setFormatter(log_formatter)
3132
log.addHandler(console_handler)
3233

34+
# On Windows, the selector event loop is required for aiodns.
35+
if os.name == "nt":
36+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
37+
3338
log.info("Cleaning out image_cache")
3439

3540
img_dir = os.listdir(IMG_CACHE)

0 commit comments

Comments
 (0)