Skip to main content

Celery is a distributed task queue library for Python. It accepts some of its configuration via environment variables–but some configuration needs to be specified as Python code.

new-celery-config is a Python package that lets you set any top-level Celery key using an environment variable containing YAML.

Installation

The latest stable can be installed via pip:

python3 -m pip install new-celery-config

Usage

(Usage) as a module

To set configuration values, you must set an environment variables for each top-level key (as documented in the Celery documentation).

Each environment variable is prefixed with NEW_CELERY_, followed by the config key name in lowercase. The value for each environment variable must be valid YAML (or JSON–remember that JSON is a subset of YAML).

You must also set the environment variable CELERY_CONFIG_MODULE to new_celery_config.as_module to enable Celery to read all of the other environment variables that you have set.

For example, setting these environment variables in the shell looks like:

export CELERY_CONFIG_MODULE=new_celery_config.as_module
export NEW_CELERY_broker_url='transport://userid:password@hostname:port/virtual_host'
export NEW_CELERY_broker_transport_options='{"visibility_timeout": 36000}'

And in your Python code, initialize the Celery object as follows:

app = Celery()

If you want to change the name of the CELERY_CONFIG_MODULE, you can use the config_from_envvar function. For example:

export ARBITRARY_CELERY_CONFIG_MODULE=new_celery_config.as_module
app.config_from_envvar("ARBITRARY_CELERY_CONFIG_MODULE")

You can test that the configuration works by examining the app.conf object:

print(app.conf.broker_transport_options)
# prints out {'visibility_timeout': 36000}

Usage (as an object)

Celery also accepts configuration in the form of a Python object. If you prefer this way, you can give Celery a new_celery_config.Config object. For example:

from celery import Celery
import new_celery_config

app = Celery()
app.config_from_object(new_celery_config.Config())

Contributing changes to new-celery-config

If you want to make changes to new-celery-config, you can clone this repository. You can run make in the root directory to show commands relevant to development.

For example:
  • make fmt automatically formats Python code.

  • make lint runs pylint and mypy to catch errors.

  • make test runs unit tests.

Metadata

Release files for new-celery-config 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for new-celery-config 0.2.0
File Size Uploaded
new_celery_config-0.2.0.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for new-celery-config 0.2.0
File Interpreter ABI Platform
new_celery_config-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.5 kB

Release files / new_celery_config-0.2.0.tar.gz

Download URL new_celery_config-0.2.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
97a58a1788485d7ea4a8a04873f1475e0b9c807244824ab59f8dfea33c6daec8
BLAKE2b-256 checksum
How to use checksums
3e577fb38c49c2b6219405d7170dff6900c73adda89ebe6e251f678313c2be3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.10 Linux/5.11.0-1028-azure

Release files / new_celery_config-0.2.0-py3-none-any.whl

Download URL new_celery_config-0.2.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a8f717bcb11f1e7d7433a9bdb89c2bef04a90b38d8dcdb36b539d9db8825992
BLAKE2b-256 checksum
How to use checksums
19e90e09b17ea72ecdc6b5ab048bc55f31a937dbb4a8233e03314ed9a409b200
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.9.10 Linux/5.11.0-1028-azure

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page