-
Notifications
You must be signed in to change notification settings - Fork 4
Add read_timeout support to prevent hanging on slow tactics #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This PR adds timeout support to prevent the pet process from hanging indefinitely when executing slow tactics (e.g., native_compute, hammer). Changes to client.py: - Add `select` module import for non-blocking I/O - Add `read_timeout` parameter to `_read_lsp_response()` (default 120s) - Use `select.select()` to wait for data with timeout - Kill pet process if it doesn't respond within timeout - Check if pet process died before each read operation - Add `read_timeout` parameter to `query()` method - Add `read_timeout` parameter to `run()` method The timeout is a hard timeout - if pet doesn't respond within the specified time, the process is killed to prevent resource exhaustion. Usage: ```python # Normal operation with default 120s timeout state = client.run(state, "ring.") # Heavy tactic with extended timeout state = client.run(state, "hammer.", read_timeout=300) # Quick check with short timeout state = client.run(state, "auto.", read_timeout=30) ``` This is a companion change to rocq-mcp PR LLM4Rocq#2 which exposes the read_timeout parameter through the MCP tool interface. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Thanks for the PR. Out of curiosity did you get this error on MacOS? Unfortunately, there is no easy way to restore the states when you kill the server. Maybe that will solve your issue? |
|
It's an old linux machine. Do you recommend moving to ml-toolbox? |
|
Yes I would give it a try if you want something that can scale. |
|
@gbdrt Could ml-toolbox also be wrapped into MCP? Or do you have a different interaction in mind? BTW a similar crash happened on a far more powerful machine when using MCP with many subagents for parallel processing. |
|
Unfortunately, that is not surprising since RocqMCP is a wrapper around pytanque. And yes we would also like to expose this new server using MCP. |
|
Do you have an ETA for that? |
|
Hi @spitters, I'm working on updating pytanque so that it works transparently with both servers (petanque and rocq-ml-server). If I'm able to make this work, then rocq-mcp should work out of the box! |
Summary
This PR adds timeout support to prevent the pet process from hanging indefinitely when executing slow tactics (e.g.,
native_compute,hammer).Problem
When a heavy tactic like
native_computeorhammeris executed on a large term, the pet process can hang for hours while consuming excessive CPU and memory. The pytanque client has no way to detect or recover from this situation - it blocks forever onreadline().Solution
Add
select()-based read timeout to_read_lsp_response():select.select()to wait for data with configurable timeoutread_timeoutparameter throughquery()andrun()methodsChanges to client.py
selectmodule import for non-blocking I/Oread_timeoutparameter to_read_lsp_response()(default 120s)read_timeoutparameter toquery()methodread_timeoutparameter torun()methodUsage
Related
This is a companion change to rocq-mcp PR #2 which exposes the
read_timeoutparameter through the MCP tool interface.Test plan
🤖 Generated with Claude Code