Fix multithreaded backend usage#6851
Merged
auvipy merged 3 commits intocelery:masterfrom Jul 11, 2021
Merged
Conversation
Add simple test with embedded worker that checks backend instance usage by threads. According merge request celery#6416 backends should be thread local.
Fix backend capturing by closure during task creation in the function `celery.app.trace.build_tracer`, as different threads may create and use celery task. It complement changes in the pull request celery#6416.
Fix flake8 errors from Celery/lint github workflow step
|
This pull request introduces 2 alerts when merging 5d21d2e into 1b67ccd - view on LGTM.com new alerts:
|
Codecov Report
@@ Coverage Diff @@
## master #6851 +/- ##
==========================================
+ Coverage 79.21% 79.23% +0.02%
==========================================
Files 138 138
Lines 16616 16612 -4
Branches 2097 2097
==========================================
+ Hits 13162 13163 +1
+ Misses 3227 3225 -2
+ Partials 227 224 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
auvipy
approved these changes
Jul 11, 2021
jeyrce
pushed a commit
to jeyrce/celery
that referenced
this pull request
Aug 25, 2021
* Add test of backend usage by threads Add simple test with embedded worker that checks backend instance usage by threads. According merge request celery#6416 backends should be thread local. * Fix backend captures in the `celery.app.trace.build_tracer` Fix backend capturing by closure during task creation in the function `celery.app.trace.build_tracer`, as different threads may create and use celery task. It complement changes in the pull request celery#6416. * Fix flake8 errors Fix flake8 errors from Celery/lint github workflow step
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.
Description
This PR adds the following fix for changes from PR #6416:
celery/app/trace.py::build_tracerfunction to prevent backend capturing into closure during Celery task creation. It prevents backend instance usage by multiple threads, as task creation and usage may be done by different threads.