From ebc522150eca6d458eb54d24594f71e28e91360a Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 1 Jan 2024 02:09:06 +0100 Subject: Patch event loop on win, Check event loop closed --- g4f/Provider/base_provider.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'g4f/Provider/base_provider.py') diff --git a/g4f/Provider/base_provider.py b/g4f/Provider/base_provider.py index f3959634..62029f5d 100644 --- a/g4f/Provider/base_provider.py +++ b/g4f/Provider/base_provider.py @@ -13,6 +13,13 @@ if sys.version_info < (3, 10): else: from types import NoneType +# Change event loop policy on windows for curl_cffi +if sys.platform == 'win32': + if isinstance( + asyncio.get_event_loop_policy(), asyncio.WindowsProactorEventLoopPolicy + ): + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + class BaseProvider(ABC): url: str working: bool = False -- cgit v1.2.3