Skip to content

Document exceptions raises by send_frame et al. #11234

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DoctorJohn
Copy link

@DoctorJohn DoctorJohn commented Jun 22, 2025

What do these changes do?

This PR updates the web reference docs of aiohttp.web.WebSocketResponse.send_frame et al. with previously missing :raise declarations.

Most notably, send_frame, send_str, send_bytes, and send_json all raise aiohttp.ClientConnectionResetError, which was previously undocumented. Additionally, it was not documented that send_frame may raise a RuntimeError if the connection is not started yet.

For reference, here are the relevant code snippets:
  • send_frame raising RuntimeError if the connection is not started yet:

    aiohttp/aiohttp/web_ws.py

    Lines 405 to 411 in 7c3afd2

    async def send_frame(
    self, message: bytes, opcode: WSMsgType, compress: Optional[int] = None
    ) -> None:
    """Send a frame over the websocket."""
    if self._writer is None:
    raise RuntimeError("Call .prepare() first")
    await self._writer.send_frame(message, opcode, compress)
  • send_frame et al. raising aiohttp.ClientConnectionResetError if the connection is closing:
    if self._closing and not (opcode & WSMsgType.CLOSE):
    raise ClientConnectionResetError("Cannot write to closing transport")

    if self.transport.is_closing():
    raise ClientConnectionResetError("Cannot write to closing transport")

Are there changes in behavior for the user?

No

Is it a substantial burden for the maintainers to support this?

pause

No

Related issue number

n/a

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder
    • name it <issue_or_pr_num>.<type>.rst (e.g. 588.bugfix.rst)

    • if you don't have an issue number, change it to the pull request
      number after creating the PR

      • .bugfix: A bug fix for something the maintainers deemed an
        improper undesired behavior that got corrected to match
        pre-agreed expectations.
      • .feature: A new behavior, public APIs. That sort of stuff.
      • .deprecation: A declaration of future API removals and breaking
        changes in behavior.
      • .breaking: When something public is removed in a breaking way.
        Could be deprecated in an earlier release.
      • .doc: Notable updates to the documentation structure or build
        process.
      • .packaging: Notes for downstreams about unobvious side effects
        and tooling. Changes in the test invocation considerations and
        runtime assumptions.
      • .contrib: Stuff that affects the contributor experience. e.g.
        Running tests, building the docs, setting up the development
        environment.
      • .misc: Changes that are hard to assign to any of the above
        categories.
    • Make sure to use full sentences with correct case and punctuation,
      for example:

      Fixed issue with non-ascii contents in doctest text files
      -- by :user:`contributor-gh-handle`.

      Use the past tense or the present tense a non-imperative mood,
      referring to what's changed compared to the last released version
      of this project.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Jun 22, 2025
Copy link

codspeed-hq bot commented Jun 22, 2025

CodSpeed Performance Report

Merging #11234 will not alter performance

Comparing DoctorJohn:fix-outdated-docs-on-ws-exceptions (8467f50) with master (7c3afd2)

Summary

✅ 59 untouched benchmarks

Copy link

codecov bot commented Jun 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.84%. Comparing base (7c3afd2) to head (8467f50).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #11234   +/-   ##
=======================================
  Coverage   98.84%   98.84%           
=======================================
  Files         131      131           
  Lines       43280    43280           
  Branches     2328     2328           
=======================================
  Hits        42782    42782           
  Misses        343      343           
  Partials      155      155           
Flag Coverage Δ
CI-GHA 98.74% <ø> (ø)
OS-Linux 98.47% <ø> (ø)
OS-Windows 96.79% <ø> (-0.01%) ⬇️
OS-macOS 97.68% <ø> (-0.01%) ⬇️
Py-3.10.11 97.33% <ø> (+<0.01%) ⬆️
Py-3.10.18 97.81% <ø> (-0.02%) ⬇️
Py-3.11.13 98.01% <ø> (ø)
Py-3.11.9 97.52% <ø> (-0.01%) ⬇️
Py-3.12.10 97.62% <ø> (-0.01%) ⬇️
Py-3.12.11 98.10% <ø> (-0.01%) ⬇️
Py-3.13.3 98.37% <ø> (-0.01%) ⬇️
Py-3.9.13 97.21% <ø> (-0.02%) ⬇️
Py-3.9.23 97.69% <ø> (-0.01%) ⬇️
Py-pypy7.3.16 87.04% <ø> (-3.51%) ⬇️
VM-macos 97.68% <ø> (-0.01%) ⬇️
VM-ubuntu 98.47% <ø> (ø)
VM-windows 96.79% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant