8000 Fix multithreaded backend usage by vznncv · Pull Request #6851 · celery/celery · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix multithreaded backend usage #6851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 11, 2021

Conversation

vznncv
Copy link
Contributor
@vznncv vznncv commented Jul 11, 2021

Description

This PR adds the following fix for changes from PR #6416:

  • Fix celery/app/trace.py::build_tracer function 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.

vznncv added 3 commits July 11, 2021 14:40
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
@lgtm-com
Copy link
lgtm-com bot commented Jul 11, 2021

This pull request introduces 2 alerts when merging 5d21d2e into 1b67ccd - view on LGTM.com

new alerts:

  • 1 for Non-exception in 'except' clause
  • 1 for Module is imported with 'import' and 'import from'

@codecov
Copy link
codecov bot commented Jul 11, 2021

Codecov Report

Merging #6851 (5d21d2e) into master (1b67ccd) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests 79.23% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
celery/app/control.py 91.36% <ø> (ø)
celery/app/trace.py 98.58% <100.00%> (-0.02%) ⬇️
celery/worker/consumer/consumer.py 94.80% <0.00%> (+1.22%) ⬆️
celery/worker/loops.py 100.00% <0.00%> (+1.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b67ccd...5d21d2e. Read the comment docs.

@auvipy auvipy merged commit 5fd1824 into celery:master 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0