summaryrefslogtreecommitdiffstats
path: root/g4f/requests.py
diff options
context:
space:
mode:
authorHeiner Lohaus <heiner@lohaus.eu>2023-10-02 17:01:15 +0200
committerHeiner Lohaus <heiner@lohaus.eu>2023-10-02 17:01:15 +0200
commitff4d9ae584cd3e9eefee6642c2a5290b63351b0a (patch)
tree59b9e30e081b2e1c46b672bc95c5610186516885 /g4f/requests.py
parent~ | g4f v-0.1.4.4 (diff)
downloadgpt4free-ff4d9ae584cd3e9eefee6642c2a5290b63351b0a.tar
gpt4free-ff4d9ae584cd3e9eefee6642c2a5290b63351b0a.tar.gz
gpt4free-ff4d9ae584cd3e9eefee6642c2a5290b63351b0a.tar.bz2
gpt4free-ff4d9ae584cd3e9eefee6642c2a5290b63351b0a.tar.lz
gpt4free-ff4d9ae584cd3e9eefee6642c2a5290b63351b0a.tar.xz
gpt4free-ff4d9ae584cd3e9eefee6642c2a5290b63351b0a.tar.zst
gpt4free-ff4d9ae584cd3e9eefee6642c2a5290b63351b0a.zip
Diffstat (limited to '')
-rw-r--r--g4f/requests.py21
1 files changed, 17 insertions, 4 deletions
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(