GLM-5.3-Flash EXL3 on 2x DGX Spark with TensorFold
Python
# Upstream TensorFold PR #218 by Jay Leaton (jayleaton), Apache-2.0, applied unchanged to v0.6.0: the client-gone
# check uses poll() instead of select(), so descriptors past 1023 are read.
diff --git tensorfold/server/cancellation.py tensorfold/server/cancellation.py
index f1f20c0..dde4890 100644
--- tensorfold/server/cancellation.py
+++ tensorfold/server/cancellation.py
@@ -27,13 +27,23 @@ class Cancellation:
raise RequestCancelled("request cancelled")
+def _readable(connection: socket.socket) -> bool:
+ """Whether a read would not block; ``poll`` where available, since ``select`` refuses descriptors past 1023."""
+
+ if hasattr(select, "poll"):
+ p = select.poll()
+ p.register(connection, select.POLLIN | select.POLLPRI)
+ return bool(p.poll(0))
+ ready, _, _ = select.select([connection], [], [], 0)
+ return bool(ready)
+
+
def socket_cancellation(connection: socket.socket) -> Cancellation:
def disconnected() -> bool:
try:
if connection.fileno() < 0:
return True
- ready, _, _ = select.select([connection], [], [], 0)
- if not ready:
+ if not _readable(connection):
return False
return connection.recv(1, socket.MSG_PEEK | socket.MSG_DONTWAIT) == b""
except BlockingIOError: