Repository navigation
Pyjoyment of Git: the coroutines of a cancelled request are cancelled, and the heartbeat of every stream of events - #54
Merged
Conversation
…, and the heartbeat of every stream of events Context.cancellable cancels the promise of a tool, a prompt, a resource or a completion, or the one of its coroutine, with Pyjo.Promise.cancel when the client abandons the request, as Pyjoyment cancels an action that is a coroutine (pyjoyment/Pyjoyment#611), whose cancellation is an error of JSON-RPC, not one of the server that would be logged. The helper heartbeat (pyjoyment/Pyjoyment#614) keeps every stream of events of Streamable HTTP open, of a subscription and of a tool that runs long, in the place of the timer of the subscriptions. Pyjoyment comes from its branch main, of [tool.uv.sources], until its release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Tests
|
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.
Two changes of the branch
mainof Pyjoyment that the server of MCP did by itself until now, with Pyjoyment of Git until its next release.Cancellation of the coroutines (pyjoyment/Pyjoyment#611)
Context.cancellable(promise)cancels the promise withPyjo.Promise.cancelwhen the client abandons the request: the connection of Streamable HTTP closes before the result, ornotifications/cancelledcomes over stdio.call_pof a tool,get_pof a prompt,read_pof a resource andcompletion/completepass the promise, or the coroutine, of their function through it. A coroutine gets the cancellation of the reactor where it waits, so itsfinallyblocks run, and a request ofPyjo.UserAgentthat it waits for closes its connection.BaseException, whichPyjo.JSON.RPCwould log as an error of the server, so the promise is rejected with an error of JSON-RPC (-32603 Request cancelled) instead. Its response is not written anyway.to_actionitself, as it is not a coroutine, so the server does it with itsContext.Heartbeat (pyjoyment/Pyjoyment#614)
heartbeatof Pyjoyment, everyserver.heartbeatseconds, from its first event. That covers a subscription and also a tool that runs long between two notifications. It replaces the recurring timer of the subscriptions, so the comment is now: heartbeatinstead of: keepalive.Pyjoyment of Git
[tool.uv.sources]takes Pyjoyment frommainof its Git repository, whichuv.lockpins at 11e47e8.Pyjoyment>=0.3.0, because the workflow Build installs the wheel with the Pyjoyment of PyPI to import it. The release of Pyjoyment replaces both: the source is removed and the lowest version is bumped. Pyjo-MCP must not be released before that.Validation
uv run python -m Pyjo.Prove -l -r t: 21 files pass. New tests cover the cancellation of a coroutine of a tool, a prompt, a resource and a completion, the cancellation over Streamable HTTP and over stdio with no error of the server, the heartbeat of the stream of a tool, and the docstring ofContext.cancellable.uv run --group sdk python -m Pyjo.Prove -l -r t/sdk: 12/12 pass.sphinx-build -W --keep-going: builds without warnings.trunk check: no issues.🤖 Generated with Claude Code