Skip to content

gh-150361: Add test for _FlowControlMixin pause_writing exception handling#150362

Open
azibom wants to merge 1 commit into
python:mainfrom
azibom:asyncio-flowcontrol-exception-test
Open

gh-150361: Add test for _FlowControlMixin pause_writing exception handling#150362
azibom wants to merge 1 commit into
python:mainfrom
azibom:asyncio-flowcontrol-exception-test

Conversation

@azibom
Copy link
Copy Markdown
Contributor

@azibom azibom commented May 24, 2026

Summary

Add a unit test for _FlowControlMixin._maybe_pause_protocol() to cover the
exception handling path when protocol.pause_writing() raises an exception.

Motivation

The _maybe_pause_protocol() method contains an exception handling branch:

except BaseException as exc:
    self._loop.call_exception_handler({
        'message': 'protocol.pause_writing() failed',
        'exception': exc,
        'transport': self,
        'protocol': self._protocol,
    })

This path is currently not explicitly covered by tests.

Changes

This PR adds a test that:

  • Triggers _maybe_pause_protocol() by exceeding the high-water mark
  • Forces protocol.pause_writing() to raise RuntimeError
  • Verifies loop.call_exception_handler() is called
  • Checks that the correct error message is passed
  • Ensures the original exception is forwarded correctly
  • Confirms _protocol_paused remains True

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

Labels

awaiting review tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant