Skip to content

Only await awaitable Trio event handler results - #217

Merged
jfhbrook merged 1 commit into
jfhbrook:mainfrom
adenzhou1350:codex/fix-trio-sync-handlers
Oct 18, 2026
Merged

jfhbrook merged 1 commit into
jfhbrook:mainfrom
adenzhou1350:codex/fix-trio-sync-handlers

Conversation

@adenzhou1350

Copy link
Copy Markdown

TrioEventEmitter unconditionally awaits each handler's return value.
A successful synchronous handler therefore emits a spurious TypeError after
doing its work. A synchronous error handler can generate another error, and two
pending emits of an async once listener fail when the second wrapper correctly
returns None without invoking the listener again.

Call the handler as before, but await its result only when it is awaitable. The
existing exception-to-error dispatch remains in place; no thread offloading or
new scheduling policy is added.

Add regressions for synchronous on/once handlers, duplicate pending once
delivery, and a synchronous error handler. Update the changelog.

Validation on CPython 3.12.13 / Trio 0.34.0:

  • Unchanged Windows source: all four new regression cases fail; the four existing
    Trio tests pass. Patched source: the complete 48-test suite passes, including
    asyncio, executor, Twisted, synchronous and uplift tests.
  • Linux public-API probe: unchanged source fails three of five cases, while the
    patched source passes all five. This is not the full Linux pytest suite.
  • Black/isort checks pass for the changed Python files; flake8 passes for
    pyee, tests and docs; git diff --check passes.

Other Python versions, Pyright and documentation builds were not run.
AI-assisted implementation and verification.

@jfhbrook

Copy link
Copy Markdown
Owner

I've gotten a number of AI assisted code contributions, and in light of that, I have a new checklist I'd like developers to run through:

  • Has the developer read DEVELOPMENT.md?
  • Have tests been updated accordingly?
  • Have AI assisted commits been marked with a 🤖 emoji?
  • Have AI assisted changes been marked with a 🤖 emoji in CHANGELOG.md?
  • Does the PR notify the use of AI coding assistants?
  • Is the developer's name in the CONTRIBUTORS.md file?

Some details on this are in DEVELOPMENT.md - I think it will help clarify any questions.

Anyway: If you can run through this checklist for me, I'd be much appreciative. Thanks!

@jfhbrook

Copy link
Copy Markdown
Owner

Also, if you are using AI, you may be interested in implementing AI skills/workflows and other agent/prompt files: #219

@adenzhou1350
adenzhou1350 force-pushed the codex/fix-trio-sync-handlers branch from 2d02994 to 07086e3 Compare October 17, 2026 22:20
@jfhbrook
jfhbrook force-pushed the codex/fix-trio-sync-handlers branch from 94ea753 to 289a0c5 Compare October 17, 2026 23:51
@jfhbrook
jfhbrook force-pushed the codex/fix-trio-sync-handlers branch from 289a0c5 to 8f292d9 Compare October 17, 2026 23:57
@jfhbrook
jfhbrook merged commit 283ce8a into jfhbrook:main Oct 18, 2026
5 checks passed
@jfhbrook

Copy link
Copy Markdown
Owner

Released in 15.0.0.

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.

2 participants