Search code examples
pythoncelerysetting

Celery: how to create a settings file?


I basically want to set the prefetch to 1. However I don't think there's a way to do this when running celery worker -prefetch=1 or something like that. I need to create a settings file but not sure what this file should be named as (settings.py?) and where this file should reside.

Do all the celery worker need this settings file?

About the prefetch value I read Understanding celery task prefetching to understand it better.


Solution

  • You can define settings for Celery by creating a module named celeryconfig and setting the appropriate directives there. The module file, celeryconfig.py, has to be available on the Python path. See configuration docs.

    You can set the prefetch value using the CELERYD_PREFETCH_MULTIPLIER directive.