diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-10-02 18:55:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-02 18:55:53 +0200 |
commit | 79a9eef02a20227340c3e90537fcb9cbe72779b4 (patch) | |
tree | 59b9e30e081b2e1c46b672bc95c5610186516885 /g4f/requests.py | |
parent | ~ | g4f v-0.1.4.4 (diff) | |
parent | Add Phind Provider (diff) | |
download | gpt4free-79a9eef02a20227340c3e90537fcb9cbe72779b4.tar gpt4free-79a9eef02a20227340c3e90537fcb9cbe72779b4.tar.gz gpt4free-79a9eef02a20227340c3e90537fcb9cbe72779b4.tar.bz2 gpt4free-79a9eef02a20227340c3e90537fcb9cbe72779b4.tar.lz gpt4free-79a9eef02a20227340c3e90537fcb9cbe72779b4.tar.xz gpt4free-79a9eef02a20227340c3e90537fcb9cbe72779b4.tar.zst gpt4free-79a9eef02a20227340c3e90537fcb9cbe72779b4.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/requests.py | 21 |
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( |