Repository navigation
Conversation
_build_id and _build_generation spelled out the same five files; _build_id also hashes servers/__init__.py.
_request_once set dispatched before sendall and branched on it in shared handlers. The connect call has its own handlers, so apart from settimeout every OSError those shared handlers saw came after dispatch. A try around sendall and the response read now maps those failures, and the outer handler covers settimeout. The "timed out waiting for Lean runtime connection" message could not occur: connect's own OSError handler turned socket.timeout into "cannot connect to Lean runtime".
ENOENT and ECONNREFUSED already raise FileNotFoundError and ConnectionRefusedError, which the handler above catches. On Linux, 61 is ENODATA, which connect does not return.
_read_line decoded the response line outside every handler, so invalid UTF-8 escaped _request_once as a raw UnicodeDecodeError instead of LeanRuntimeProtocolError, and the UnicodeDecodeError clause around json.loads could not run. _read_line now returns bytes, and the caller decodes them inside that clause.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One fix and three cleanups in
servers/lean_client.py(+27/-39), plus one test. The fix changes the exception type for a malformed reply. The cleanups keep every exception class and every message a caller could see.Fix: non-UTF-8 replies.
_read_linedecoded the response line itself, outside every handler in_request_once. A reply with invalid UTF-8 therefore escaped as a rawUnicodeDecodeErrorinstead ofLeanRuntimeProtocolError, and theUnicodeDecodeErrorclause aroundjson.loadscould not run._read_linenow returns bytes, and the caller decodes them inside that clause.test_non_utf8_response_is_a_protocol_errorfails on main with theUnicodeDecodeErrorand passes here.Cleanups
_request_onceset adispatchedflag beforesendalland branched on it in shared handlers. The connect call has its own handlers, so apart fromsettimeout, everyOSErrorthe shared handlers saw came after dispatch. Atryaroundsendalland the read now maps those failures, and the outer handler coverssettimeout. The no-retry rule after dispatch is unchanged, andtest_connected_send_failure_is_never_retriedstill pins it: it fails if the post-dispatch handler raisesLeanRuntimeUnavailable. The "timed out waiting for Lean runtime connection" message is gone because it could not occur: connect's ownOSErrorhandler turnedsocket.timeoutinto "cannot connect to Lean runtime: ...".errno in {2, 61, 111}check is gone. ENOENT and ECONNREFUSED already raiseFileNotFoundErrorandConnectionRefusedError, which the clause above catches. On Linux, 61 is ENODATA, which connect does not return._build_idand_build_generationlisted the same five files; they now share_RUNTIME_SOURCES._build_idstill hashesservers/__init__.pyfirst, so its input order is unchanged.No open PR edits
lean_client.py. #168, #111 and #105 edittests/test_shared_lean_runtime.py; each merges cleanly with this branch, and the merged file passes with #111 (which contains #168, 62 passed) and with #105 (39 passed).Validation at exact head
301a1df6:ruff check autoform_cli servers testsis clean, andtests/test_shared_lean_runtime.pypasses (38). Intests/test_plugin_runtime.py, 3 pass; the fourth,test_wheel_contains_only_the_minimal_runtime, fails the same way on main in this checkout, becauseuv buildreads a parent directory'spyproject.toml. CI runs it.