Skip to content

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

Merged
kumaraditya303 merged 2 commits into
python:mainfrom
azibom:asyncio-flowcontrol-exception-test
Jul 24, 2026
Merged

gh-150361: Add test for _FlowControlMixin pause_writing exception handling#150362
kumaraditya303 merged 2 commits into
python:mainfrom
azibom:asyncio-flowcontrol-exception-test

Conversation

@azibom

@azibom azibom commented May 24, 2026

Copy link
Copy Markdown
Contributor

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

@kumaraditya303
kumaraditya303 enabled auto-merge (squash) July 24, 2026 14:04
@kumaraditya303
kumaraditya303 merged commit ad1cea6 into python:main Jul 24, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants