-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Add support for custom celery configs #45038
base: main
Are you sure you want to change the base?
Changes from all commits
6084c54
03431e6
bfaf924
303af23
382d45e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -330,6 +330,17 @@ config: | |||||||||
type: string | ||||||||||
example: ~ | ||||||||||
default: "False" | ||||||||||
extra_celery_config: | ||||||||||
description: | | ||||||||||
Extra celery configs to include in the celery worker. | ||||||||||
Any of the celery config can be added to this config and it | ||||||||||
will be applied while starting the celery worker. e.g. {"worker_max_tasks_per_child": 10} | ||||||||||
See also: | ||||||||||
https://docs.celeryq.dev/en/stable/userguide/configuration.html#configuration-and-defaults | ||||||||||
version_added: ~ | ||||||||||
type: string | ||||||||||
example: ~ | ||||||||||
default: "{}" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I also did not know but defaults seem to be Format-String formatted and the string "{}" is an invalid sequence. So to effectively have an
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay ... interesting, this also resolves the CI problem - it seems the constrains also can not be built as the templating fails there. I did a PR with the fixes applied as test and this is turning green: #45160
Suggested change
|
||||||||||
celery_broker_transport_options: | ||||||||||
description: | | ||||||||||
This section is for specifying options which can be passed to the | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -399,3 +399,12 @@ def test_celery_task_acks_late_loaded_from_string(): | |
# reload celery conf to apply the new config | ||
importlib.reload(default_celery) | ||
assert default_celery.DEFAULT_CELERY_CONFIG["task_acks_late"] is False | ||
|
||
|
||
@conf_vars({("celery", "extra_celery_config"): '{"worker_max_tasks_per_child": 10}'}) | ||
def test_celery_extra_celery_config_loaded_from_string(): | ||
import importlib | ||
|
||
# reload celery conf to apply the new config | ||
importlib.reload(default_celery) | ||
assert default_celery.DEFAULT_CELERY_CONFIG["extra_celery_config"] == {"worker_max_tasks_per_child": 10} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you did not hit it (yet) as CI was broken, in the test baloon PR #45160 the check fail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As CI did not get to this stage (yet) as failing earlier, there will be a problem reported by mypy for providers like:
As the JSON result can be other values than a dict (irrespective of the type declaration above, you need to use: