{{ message }}
Repository navigation
Conversation
A task that raises cannot change a response that has already been sent, and the exception never reaches the path operation function, so a failed task looks identical to a successful one from the outside. The example lives in docs_src with a test, and the section points at a task queue for work that needs to survive a restart.
Contributor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This picks up #14599, which the inactivity bot closed while I was away — my fault for going quiet. The
bot suggested opening a new PR, so here it is, rewritten rather than restored.
The gap: a background task that raises cannot change a response that has already been sent, and the
exception never reaches the path operation function. From the outside a failed task looks exactly like
a successful one. #2505, #2604 and #3589 all come back to that, and the tutorial does not mention it.
What changed since the earlier attempt, after reading how the rest of the docs are written:
docs_src/background_tasks/tutorial003_py310.pyand is referenced with{* ... *}, so it is covered by a test like the other examples rather than being an inline block/// tipinstead of!!! tip, which is what the other 37 files in the tutorial useTwo tests in
tests/test_tutorial/test_background_tasks/test_tutorial003.py: the example runs, and atask that raises still returns 200 while the error reaches the log — which is the behaviour the section
is actually describing.
5 passedin that directory.Happy to trim it further if it is more than you want in a tutorial page.