mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-05-07 17:22:04 +00:00
add jaxxks mutex lock for proxy during request
This commit is contained in:
parent
2acf209972
commit
088c01e2a7
1 changed files with 20 additions and 19 deletions
39
koboldcpp.py
39
koboldcpp.py
|
|
@ -3983,26 +3983,27 @@ class KcppProxyHandler(http.server.BaseHTTPRequestHandler):
|
|||
self.wfile.write(html_502.encode("utf-8"))
|
||||
return
|
||||
|
||||
self.send_response(resp.status, resp.reason) # forward response headers
|
||||
for k, v in resp.getheaders():
|
||||
lk = k.lower()
|
||||
if lk in self.HOP_BY_HOP:
|
||||
continue
|
||||
self.send_header(k, v)
|
||||
self.end_headers()
|
||||
self.close_connection = True
|
||||
with proxy_reload_lock:
|
||||
self.send_response(resp.status, resp.reason) # forward response headers
|
||||
for k, v in resp.getheaders():
|
||||
lk = k.lower()
|
||||
if lk in self.HOP_BY_HOP:
|
||||
continue
|
||||
self.send_header(k, v)
|
||||
self.end_headers()
|
||||
self.close_connection = True
|
||||
|
||||
try: # stream response
|
||||
while True:
|
||||
chunk = resp.read(self.STREAM_CHUNK)
|
||||
if not chunk:
|
||||
break
|
||||
self.wfile.write(chunk)
|
||||
self.wfile.flush()
|
||||
except (BrokenPipeError, ConnectionResetError):
|
||||
pass
|
||||
finally:
|
||||
conn.close()
|
||||
try: # stream response
|
||||
while True:
|
||||
chunk = resp.read(self.STREAM_CHUNK)
|
||||
if not chunk:
|
||||
break
|
||||
self.wfile.write(chunk)
|
||||
self.wfile.flush()
|
||||
except (BrokenPipeError, ConnectionResetError):
|
||||
pass
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
# proxy all HTTP methods
|
||||
do_GET = _handle
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue