Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

fix(serve): only set TCP_NODELAY on TCP sockets, and never fail a connection over it

Nandakishor3b0998b26d3d
diff --git a/laya/serve.py b/laya/serve.py
index fe18ac32..ed08d39a 100644
--- a/laya/serve.py
+++ b/laya/serve.py
@@ -528,7 +528,12 @@ def main() -> None:
# asyncio only sets TCP_NODELAY when the accepted socket reports IPPROTO_TCP, and
# on macOS and Windows it reports 0, so Nagle delays small responses (#620).
def connection_made(self, transport):
- transport.get_extra_info("socket").setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
+ sock = transport.get_extra_info("socket")
+ if sock is not None and sock.family in (socket.AF_INET, socket.AF_INET6):
+ try:
+ sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
+ except OSError:
+ pass # a latency hint, never a reason to drop the connection
super().connection_made(transport)
uvicorn.run(