From ff4d9ae584cd3e9eefee6642c2a5290b63351b0a Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Mon, 2 Oct 2023 17:01:15 +0200 Subject: Add Phind Provider Add release_curl in url_cffi requets Support create image response in Bing --- g4f/requests.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'g4f/requests.py') diff --git a/g4f/requests.py b/g4f/requests.py index 5dd2f56e..c51d9804 100644 --- a/g4f/requests.py +++ b/g4f/requests.py @@ -97,8 +97,7 @@ class StreamRequest: self.enter.set_result(None) self.queue.put_nowait(None) - #self.loop.call_soon(self.session.rel, self.curl) - return + self.loop.call_soon(self.release_curl) async def fetch(self) -> StreamResponse: if self.handle: @@ -146,8 +145,22 @@ class StreamRequest: return await self.fetch() async def __aexit__(self, *args): - return - #self.session.release_curl(self.curl) + self.release_curl() + + def release_curl(self): + if is_newer_0_5_10: + self.session.release_curl(self.curl) + return + if not self.curl: + return + self.curl.clean_after_perform() + if is_newer_0_5_9: + self.session.acurl.remove_handle(self.curl) + elif not self.handle.done() and not self.handle.cancelled(): + self.session.acurl.set_result(self.curl) + self.curl.reset() + self.session.push_curl(self.curl) + self.curl = None class StreamSession(AsyncSession): def request( -- cgit v1.2.3