Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526"""A stream connection that reads its first batch and then stops reading."""
import socket
def unread_stream(app, path): connection = socket.socket() connection.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 1024) connection.settimeout(15) connection.connect(("127.0.0.1", app.connection["port"])) connection.sendall( ( f"GET {path} HTTP/1.1\r\nHost: localhost:{app.connection['port']}\r\n" f"Authorization: Bearer {app.connection['token']}\r\n" "Accept: text/event-stream\r\n\r\n" ).encode() ) # Read only the readiness batch, then leave all later socket data unread. initial = b"" while b"data: " not in initial or b"\n\n" not in initial.split(b"data: ", 1)[1]: part = connection.recv(1) if not part: raise AssertionError("stream closed before readiness") initial += part return connection