From 62d66b7daf71f9bbe68111deec2d657f9d15504b Mon Sep 17 00:00:00 2001 From: Pratham Dubey <134331217+prathamdby@users.noreply.github.com> Date: Tue, 26 Mar 2024 16:37:38 +0530 Subject: [PATCH] src: Bot: Guard the platform-specific attribute of the asyncio package --- src/Bot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bot.py b/src/Bot.py index 812c259..36d510d 100644 --- a/src/Bot.py +++ b/src/Bot.py @@ -44,8 +44,9 @@ def main() -> None: default_event_loop_policy = asyncio.get_event_loop_policy() import g4f # Trigger g4f event loop policy set # noqa: F401 # pylint: disable=unused-import # isort:skip - if isinstance(asyncio.get_event_loop_policy(), asyncio.WindowsSelectorEventLoopPolicy): - asyncio.set_event_loop_policy(default_event_loop_policy) + if hasattr(asyncio, "WindowsSelectorEventLoopPolicy"): + if isinstance(asyncio.get_event_loop_policy(), asyncio.WindowsSelectorEventLoopPolicy): + asyncio.set_event_loop_policy(default_event_loop_policy) loaded_modules = load_modules(app) app.run()