Commit 4d2cab10

andrewchernyh <andrew.chernyh@gmail.com>
2022-05-20 05:47:00
Fix http reuse connections (#94)
Co-authored-by: andrey@inworld.ai <andrey@inworld.ai>
1 parent 0b07e1e
Changed files (1)
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: "):