Skip to content

ASYNC102 should allow aclose_forcefully #446

Closed

Description

@A5rocks
async def _run_handler(stream: StreamT, handler: Handler[StreamT]) -> None:
    try:
        await handler(stream)
    finally:
        await trio.aclose_forcefully(stream)  # E

this should be allowed, I think. It currently gets this error message:

src/trio/_highlevel_serve_listeners.py:36:9: ASYNC102 await inside try/finally on line 33 must have shielded cancel scope with a timeout.

but this relies on the implementation of aclose_forcefully, which is documented as cancelling immediately.

Activity

  1. A5rocks commented on Apr 22, 2026

    @A5rocks
    ContributorAuthor

    Same for trio.lowlevel.cancel_shielded_checkpoint, which the name suggests is shielded (and adding a timeout wouldn't make sense, since it's just a single tick).

  2. added a commit that references this issue on Apr 22, 2026
    22f9ba8
  3. added a commit that references this issue on Apr 22, 2026
    129f952
  4. A5rocks commented on Apr 22, 2026

    @A5rocks
    ContributorAuthor

    Oops, sorry, await trio.lowlevel.cancel_shielded_checkpoint() too! Should I open a new issue?

  5. Zac-HD commented on Apr 23, 2026

    @Zac-HD
    Member

    No need, I'll add that in. (spending a few days vibe-issue-fixing 😁)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rule improvementImprovement for currently existing rule

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions