simplify Athena runtime and centralize MCP management

This commit is contained in:
Mikei386
2026-08-26 09:57:38 +02:00
parent 104c9904a5
commit ab671a6396
31 changed files with 918 additions and 419 deletions
+16
View File
@@ -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: