Add tests for exception handling in _FlowControlMixin._maybe_pause_protocol
The _FlowControlMixin._maybe_pause_protocol() method contains a defensive
exception handling path when calling protocol.pause_writing():
try:
self._protocol.pause_writing()
except (SystemExit, KeyboardInterrupt):
raise
except BaseException as exc:
self._loop.call_exception_handler({
'message': 'protocol.pause_writing() failed',
'exception': exc,
'transport': self,
'protocol': self._protocol,
})
Current situation
While normal flow-control behavior is covered by existing tests, the exception
handling branch (when pause_writing() raises an error) is not explicitly
tested.
Proposed test coverage
This issue proposes adding a unit test to ensure that:
Why this matters
This behavior is part of asyncio’s flow control robustness and ensures that
protocol-level errors do not silently break transport state transitions.
Explicit testing prevents regressions in error-handling logic inside
_FlowControlMixin.
Linked PRs
Add tests for exception handling in
_FlowControlMixin._maybe_pause_protocolThe
_FlowControlMixin._maybe_pause_protocol()method contains a defensiveexception handling path when calling
protocol.pause_writing():Current situation
While normal flow-control behavior is covered by existing tests, the exception
handling branch (when
pause_writing()raises an error) is not explicitlytested.
Proposed test coverage
This issue proposes adding a unit test to ensure that:
protocol.pause_writing()is called when write buffer exceeds high-water markIf
pause_writing()raises an exception:loop.call_exception_handler()is invoked"protocol.pause_writing() failed"_protocol_paused = TruestateWhy this matters
This behavior is part of asyncio’s flow control robustness and ensures that
protocol-level errors do not silently break transport state transitions.
Explicit testing prevents regressions in error-handling logic inside
_FlowControlMixin.Linked PRs