Repository navigation
fix: stop logging a failed task's error twice - #44
Merged
Merged
Conversation
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.
When a task that uses
FromDIraised, its traceback was logged twice. The first copy is taskiq's "Exception found while executing function." The second is a teardown warning, "Exception found on dependency teardown", which taskiq-dependencies logs when the exception it throws into a generator dependency withathrowcomes back out.build_di_containerlet it through, so every failed task reported its error a second time, as if teardown had failed.build_di_containernow catchesExceptionat theyieldand returns. Theasync withstill closes the per-task container, and taskiq has already recorded the failure in the task result before it callsathrow. An error raised while closing the container, such as aFinalizerError, happens outside thetry, so it is still logged as a teardown error.BaseExceptions such asCancelledErrorare not caught.This makes our dependency differ from a plain taskiq generator dependency, which logs the same duplicate. In exchange, a teardown warning from our dependency now always means a real teardown problem.
The new test captures the
taskiq.dependencies.ctxlog for a failing task and fails on main with that warning. The existingtest_per_task_child_closed_on_task_errorstill checks that the container closes on the error path.