It seems like server.run(lean_interact.Command(…)) starts failing after ~560 issued commands.
The following code reproduces the issue consistently for me:
#!/usr/bin/env python3
import time
import lean_interact
if __name__ == "__main__":
server = lean_interact.LeanServer(lean_interact.LeanREPLConfig())
n = 0
started = int(time.time())
last_update = started
while True:
n += 1
if last_update != int(time.time()):
elapsed = int(time.time()) - started
commands_per_second = n // elapsed
print(
f"{elapsed} seconds elapsed, {n} issued commands, {commands_per_second} commands/second"
)
last_update = int(time.time())
response = server.run(lean_interact.Command(cmd=f"#check Nat"))
assert response.messages
assert response.messages[0].data == "Nat : Type"
Output:
59 seconds elapsed, 532 issued commands, 9 commands/second
60 seconds elapsed, 541 issued commands, 9 commands/second
61 seconds elapsed, 549 issued commands, 9 commands/second
62 seconds elapsed, 557 issued commands, 8 commands/second
Traceback (most recent call last):
…
raise BrokenPipeError("The Lean server returned no output.")
BrokenPipeError: The Lean server returned no output.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
…
raise ConnectionAbortedError(
...<5 lines>...
) from e
ConnectionAbortedError: The Lean server closed unexpectedly. Possible reasons (not exhaustive):
- An uncaught exception in the Lean REPL (for example, an inexistent file has been requested)
- Not enough memory and/or compute available
- The cached Lean REPL is corrupted. In this case, clear the cache using the `clear-lean-cache` command.
Environment:
% python3 --version
Python 3.13.2
% sw_vers
ProductName: macOS
ProductVersion: 15.1.1
BuildVersion: 24B2091
It seems like
server.run(lean_interact.Command(…))starts failing after ~560 issued commands.The following code reproduces the issue consistently for me:
Output:
Environment: