Handle broken pipe error (#572)

This commit is contained in:
Eugene Palmoff 2023-12-21 14:51:36 +05:00 committed by GitHub
parent 3f863eed72
commit a787ebe7cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -626,7 +626,7 @@ class ServerRequestHandler(http.server.SimpleHTTPRequestHandler):
await asyncio.gather(*tasks) await asyncio.gather(*tasks)
generate_result = generate_task.result() generate_result = generate_task.result()
return generate_result return generate_result
except ConnectionAbortedError as cae: # attempt to abort if connection lost except (BrokenPipeError, ConnectionAbortedError) as cae: # attempt to abort if connection lost
print(cae) print(cae)
handle.abort_generate() handle.abort_generate()
time.sleep(0.1) #short delay time.sleep(0.1) #short delay