simplify Athena runtime and centralize MCP management
This commit is contained in:
@@ -62,6 +62,7 @@ import logging
|
||||
import os
|
||||
import queue
|
||||
import re
|
||||
import select
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -2098,6 +2099,21 @@ class Handler(BaseHTTPRequestHandler):
|
||||
chunk = resp.read1(16384)
|
||||
if not chunk:
|
||||
break
|
||||
# A closed downstream socket may still accept one small write
|
||||
# into the kernel buffer. Detect the peer FIN before writing so
|
||||
# slow upstream streams are cancelled promptly and do not keep
|
||||
# an inference lease occupied until generation completes.
|
||||
try:
|
||||
readable, _, _ = select.select([self.connection], [], [], 0)
|
||||
if readable:
|
||||
flags = socket.MSG_PEEK | getattr(socket, "MSG_DONTWAIT", 0)
|
||||
if self.connection.recv(1, flags) == b"":
|
||||
log.info("Client trennte Streaming-Verbindung; Upstream wird abgebrochen")
|
||||
break
|
||||
except (BlockingIOError, InterruptedError):
|
||||
pass
|
||||
except OSError:
|
||||
break
|
||||
self.wfile.write(chunk)
|
||||
self.wfile.flush()
|
||||
except (OSError, http.client.HTTPException) as e:
|
||||
|
||||
Reference in New Issue
Block a user