Skip to main content

new_celery_config specifies Celery configuration via environment variables.

Reason this release was yanked:

Does not handle false values. Upgrade to 0.1.2 or newer.

Project description

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

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).

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

export BROKER_URL='transport://userid:password@hostname:port/virtual_host'
export NEW_CELERY_broker_transport_options='{"visibility_timeout": 36000}'

Usage (as an object)

Then, when you create your Celery object in code, you can pass it 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())

and 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 a module

Celery also accepts configuration from a module with top-level variables mapping to config keys. The location of this module can be set via an environment variable.

If your existing configuration is already in an module, then your code probably already looks like:

app = Celery()
app.config_from_envvar("ARBITRARY_CELERY_CONFIG_MODULE")

where the value of ARBITRARY_CELERY_CONFIG_MODULE is something like your_project.celeryconfig.

If you don’t want to change your Python code to read, then just set your ARBITRARY_CELERY_CONFIG_MODULE environment variable to new_celery_config.as_module and everything will work as expected.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

new_celery_config-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

new_celery_config-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file new_celery_config-0.1.0.tar.gz.

File metadata

  • Download URL: new_celery_config-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.9.2 Linux/5.4.0-1041-azure

File hashes

Hashes for new_celery_config-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8535ba76a2c10ae28ef46424d61fccab3f0f527de609c53986bccdb563b425e2
MD5 35f81356c20805d82e963c5d552a4116
BLAKE2b-256 2d116e283a7b078e73f091c51a6219a2ea5e6d12a84a9ae080f13495c0d16580

See more details on using hashes here.

File details

Details for the file new_celery_config-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: new_celery_config-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.9.2 Linux/5.4.0-1041-azure

File hashes

Hashes for new_celery_config-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 927eda085b31d9370e0caad7c51aa427448b04ff1199e7c19f6d49d782e93f13
MD5 afa6821ed10bf3453bd446363ef540e3
BLAKE2b-256 7a29f1701212b3ec39d49f4c0853ff7e73cdd6b1b1d4e6cdba48636af5ce478e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page