Skip to content

Comments

all teardown callbacks are called despite errors#5928

Merged
davidism merged 1 commit intomainfrom
teardown
Feb 20, 2026
Merged

all teardown callbacks are called despite errors#5928
davidism merged 1 commit intomainfrom
teardown

Conversation

@davidism
Copy link
Member

Previously, Flask documented that teardown callbacks must not fail. Now, all callbacks will be called, and any errors are collected to be raised at the end. This applies to app and request teardown callbacks and signals. On Python >= 3.11, this will result in an ExceptionGroup each for app and request teardown, collected in an ExceptionGroup for overall teardown. On 3.10, the first collected error is raise, which basically matches what happens now.

Also adjusts a bunch of tests to clean up any resources. None were failing with ResourceWarning, but this ensures they don't even if they fail for some other reason.

@davidism davidism added this to the 3.2.0 milestone Feb 20, 2026
@davidism davidism merged commit c34d6e8 into main Feb 20, 2026
14 checks passed
@davidism davidism deleted the teardown branch February 20, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant