Skip to content

Commit a5caf79

Browse files
committed
make the comments concise
1 parent cd7dfc8 commit a5caf79

1 file changed

Lines changed: 14 additions & 20 deletions

File tree

pyk/src/pyk/kore/rpc.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,11 @@ def __exit__(self, *args: Any) -> None:
8686
def close(self) -> None: ...
8787

8888
def send_interrupt(self, data: str) -> None:
89-
"""Inject `data` onto the live connection to abort an in-flight request.
89+
"""Send `data` on the live connection without waiting for a reply.
9090
91-
Used to deliver an out-of-band `cancel` message on a connection whose response is
92-
currently being awaited by another thread, so the server aborts the in-flight request
93-
and the awaiting thread receives a "cancelled" error shortly after. The connection is
94-
left open and usable for subsequent requests. The default implementation does nothing;
95-
transports backed by a persistent, multiplexable connection should override it.
91+
Used to deliver a `cancel` to a connection whose reply another thread is already
92+
awaiting. Default: no-op. Override only for connections that can be written to
93+
while a request is in flight.
9694
"""
9795
...
9896

@@ -155,11 +153,9 @@ def close(self) -> None:
155153
self._sock.close()
156154

157155
def send_interrupt(self, data: str) -> None:
158-
# Inject `data` (a `cancel` request) onto the current socket without reading a response:
159-
# the server's read loop picks it up concurrently and aborts the in-flight request, so the
160-
# thread blocked in `_request`'s `readline` receives the server's "cancelled" error for that
161-
# request. The connection is left open and reusable -- no reconnect. The leading newline just
162-
# guarantees the injected value is separated from any preceding request on the byte stream.
156+
# Write the cancel to the socket but don't read the reply: the thread already blocked in
157+
# `_request`'s `readline` will read the server's "cancelled" reply. The socket stays open.
158+
# The leading newline separates the cancel from the request bytes already on the stream.
163159
self._sock.sendall(b'\n' + data.encode())
164160

165161
def _request(self, req: str) -> str:
@@ -344,10 +340,9 @@ def close(self) -> None:
344340
self._transport.close()
345341

346342
def interrupt(self) -> None:
347-
# Send a `cancel` request on the live connection so the server aborts the in-flight request
348-
# (the request currently being awaited by another thread). The cancel itself gets no response;
349-
# the awaiting thread receives the server's "cancelled" error for the original request. We do
350-
# not touch `_req_id` (it is owned by the requesting thread); the cancel id is purely for traceability.
343+
# Send a `cancel` so the server aborts the in-flight request. The cancel gets no reply of its
344+
# own; the thread awaiting that request gets a "cancelled" error instead. The id is only for
345+
# logs, so we derive it from the last request rather than touching the requester's `_req_id`.
351346
cancel_id = f'{self._last_request_id}-cancel' if self._last_request_id is not None else 'cancel'
352347
payload = {
353348
'jsonrpc': self._JSON_RPC_VERSION,
@@ -1056,12 +1051,11 @@ def last_request_id(self) -> str | None:
10561051
return self._client.last_request_id
10571052

10581053
def interrupt(self) -> None:
1059-
"""Abort an `execute`/`simplify`/… request currently in flight on another thread.
1054+
"""Abort an `execute`/`simplify`/… request running on another thread.
10601055
1061-
Sends a `cancel` request on the live connection so the server stops computing the
1062-
in-flight request; the interrupted call then raises a "cancelled" error and the
1063-
connection stays open and usable. Only effective for the single-socket transport;
1064-
a no-op for transports that cannot inject onto an in-flight request (e.g. HTTP).
1056+
Sends a `cancel` so the server stops computing; the interrupted call raises a
1057+
"cancelled" error and the connection stays usable. Works on the single-socket
1058+
transport only; a no-op for HTTP (one connection per request, nothing to cancel).
10651059
"""
10661060
self._client.interrupt()
10671061

0 commit comments

Comments
 (0)