Skip to main content

new_celery_config specifies Celery configuration via environment variables.

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

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

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.2.tar.gz (4.1 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.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: new_celery_config-0.1.2.tar.gz
  • Upload date:
  • Size: 4.1 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.2.tar.gz
Algorithm Hash digest
SHA256 2aadb5bcbe81a731b5710092ed9d49962a16d8651ee0cde53e81e2219e947781
MD5 4a672571f2b7b7dbfbdd93ef580ce732
BLAKE2b-256 dfa654a6b6099b950fa110201e09013d3645cca06efd3899de98c076b052193a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: new_celery_config-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e1825da2c7ac5f385b88ed1c1be34288ffabdeba0579b057f8e27e0dcf0ce46f
MD5 f73b8d6f52c635db0427ca15d061970e
BLAKE2b-256 5209a473b8367564cf404e82e62a802ed1b157f2c443f6bd384df43e7e5e278f

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