Skip to content

Pyjoyment of Git: the coroutines of a cancelled request are cancelled, and the heartbeat of every stream of events - #54

Merged
dex4er merged 1 commit into
mainfrom
pyjoyment-cancel-heartbeat
Nov 12, 2026
Merged

dex4er merged 1 commit into
mainfrom
pyjoyment-cancel-heartbeat

Conversation

@dex4er

@dex4er dex4er commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Two changes of the branch main of 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 with Pyjo.Promise.cancel when the client abandons the request: the connection of Streamable HTTP closes before the result, or notifications/cancelled comes over stdio.
  • call_p of a tool, get_p of a prompt, read_p of a resource and completion/complete pass the promise, or the coroutine, of their function through it. A coroutine gets the cancellation of the reactor where it waits, so its finally blocks run, and a request of Pyjo.UserAgent that it waits for closes its connection.
  • The cancellation is a BaseException, which Pyjo.JSON.RPC would 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.
  • Pyjoyment does not cancel the action of to_action itself, as it is not a coroutine, so the server does it with its Context.

Heartbeat (pyjoyment/Pyjoyment#614)

  • Every stream of events of Streamable HTTP now gets the helper heartbeat of Pyjoyment, every server.heartbeat seconds, 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 : heartbeat instead of : keepalive.

Pyjoyment of Git

  • [tool.uv.sources] takes Pyjoyment from main of its Git repository, which uv.lock pins at 11e47e8.
  • The lowest version stays 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 of Context.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

…, 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>
@dex4er dex4er added this to the 0.2.1 milestone Nov 12, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 Pyjo-MCP | 🛠️ Build #35848342 | 📁 Comparing b8af29e against latest (b30b440)

  🔍 Preview build  

6 files changed · ± 6 modified

± Modified

@github-actions

Copy link
Copy Markdown
Contributor

Tests

Job Tests Passed ✅ Skipped ⚠️ Failed ❌ Log
prove (python 3.12) 242 241 1 0 ✅ 131420403343
prove (python 3.13) 242 241 1 0 ✅ 131420403678
prove (python 3.14) 242 241 1 0 ✅ 131420403666
prove (python 3.15) 242 241 1 0 ✅ 131420403845
prove (python 3.15t) 242 241 1 0 ✅ 131420403513
prove (python pypy3.12) 242 241 1 0 ✅ 131420403448
sdk (python 3.15) 12 12 0 0 ✅ 131420402962
All 1464 1458 6 0 ✅

The run of the workflow

@dex4er
dex4er merged commit 6a135b8 into main Nov 12, 2026
13 checks passed
@dex4er
dex4er deleted the pyjoyment-cancel-heartbeat branch November 12, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant