Fixed
- A generator whose
finallygets stuck after an encoding failure or an interrupted
send no longer keeps the response open forever (#217). Previously the background
task never ran, and uvicorn without a graceful timeout could not finish shutting
down. - Body iterators are now closed when SSE event encoding fails, so generator cleanup
runs before the error escapes (#223). - Encoding no longer mutates event dictionaries yielded by a generator (#225).
Added
cleanup_timeoutparameter onEventSourceResponse: seconds to wait for the
generator's cleanup after an encoding failure or interrupted send. Default:30.0.
Nonemeans no limit.
Behaviour change
- Cleanup that takes longer than 30s on this path is now cancelled, and a warning is
logged. Pass a largercleanup_timeout, orNone, to allow more time. - The deadline only reaches cleanup that can be cancelled. A nested shield or a
blocking call infinallycan still hang.
Dependencies
- Upgraded locked dependencies, including Twisted 26.10.0, which addresses open
security advisories against Twisted 26.4.0 and earlier. The lockfile does not ship
with the package: if you use Daphne, make sure your own environment has Twisted
26.10.0 or later.
What's Changed
- Close body iterators when SSE event encoding fails by @Claire-ovo in #223
- fix: avoid mutating event dictionaries during encoding by @HuaTNA in #225
- fix: bound shielded iterator cleanup with cleanup_timeout by @sysid in #234
New Contributors
- @Claire-ovo made their first contribution in #223
- @HuaTNA made their first contribution in #225
Full Changelog: v3.6.0...v3.7.0