Saturday 15 September 2012

python - How do I statically configure Celery application differently in production and development? -


I want to use cerberary to implement a work queue for working longer, such as external APIs ( Like to send texle SMSs) However, I use different API credentials in production and development.

I can not understand how to configure the solarium to pass in the appropriate API credentials (for example, from command line) related to my application code (which launches celery functions) Specifies whether the sealary queue is said to talk with both lines of development and production?

Thanks for any help you can avi

Edit: An extra bonus for an example of using the --config option of celery.

The way I do it is using an environment variable. As a simple example ...

  By # conference, my configuration files are in the "configs / XXX.ini" file, which has the # XXX configuration name (e.g., "staging.ini ") Config_filename = os.path.join ('configs', os.environ ['CELERY_CONFIG'] + '.i') Configuration = read_config_file (config_filename) # You can now create celery by using your configuration ... Celery = celevery ('mymodule', broker = configuration ['CELERY_BROKER_URL']) @clerery. Tak def add_stuff (x, y): ....   

You are running from the command line As such ... Export is an example of doing something like CELERY_CONFIG = Staging Selerie-A Mymodule worker

, but he says "how do I do this which is not so ugly? "As far as I am concerned, it is quite acceptable, and" ugly "does not at all.

No comments:

Post a Comment