From 5a92f74847d7bb8e03bed91a07b5493461bb25cb Mon Sep 17 00:00:00 2001 From: "andrey@inworld.ai" Date: Thu, 19 May 2022 16:31:43 +0700 Subject: [PATCH] Fix http reuse connections --- openai/api_requestor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openai/api_requestor.py b/openai/api_requestor.py index d2160c1810..2b0982be75 100644 --- a/openai/api_requestor.py +++ b/openai/api_requestor.py @@ -62,7 +62,9 @@ def parse_stream(rbody): for line in rbody: if line: if line == b"data: [DONE]": - return + # return here will cause GeneratorExit exception in urllib3 + # and it will close http connection with TCP Reset + continue if hasattr(line, "decode"): line = line.decode("utf-8") if line.startswith("data: "):