Skip to content

Commit 4d2cab1

Browse files
Fix http reuse connections (#94)
Co-authored-by: [email protected] <[email protected]>
1 parent 0b07e1e commit 4d2cab1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

openai/api_requestor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def parse_stream(rbody):
6262
for line in rbody:
6363
if line:
6464
if line == b"data: [DONE]":
65-
return
65+
# return here will cause GeneratorExit exception in urllib3
66+
# and it will close http connection with TCP Reset
67+
continue
6668
if hasattr(line, "decode"):
6769
line = line.decode("utf-8")
6870
if line.startswith("data: "):

0 commit comments

Comments
 (0)