Search code examples
pythoncelerypyramid

Pyramid periodic task with Celery


I'm try to use pyramid_celery. I managed to run simple tasks. But how with pyramid run of a periodic tasks? Where I need to write CELERYBEAT_SCHEDULE?


Solution

  • Using Pyramid with Celery does not require using pyramid_celery module - the latter is just a thin integration layer which may or may not make your life easier. In your case it looks like it doesn't make your life easier, right?

    Both Pyramid and Celery have excellent and very detailed documentation. pyramid_celery does not have detailed documentation. From my reading the code it looks like it reads celery configuration from paster .ini file (development.ini in case of pyramid_celery_demo app) - I have no idea how to stick a nested dict into an .ini file, but some commit messages suggest that it somehow should work.

    In short, your options are:

    • read the code of pyramid_celery and figure out how it supposed to work

    • write to the author of the package

    • drop the package and use plain Pyramid and plain Celery, enjoying nice and clear documentation.

    Further reading the code suggests that they 'eval()' string values read from the .ini file to convert them to python structures, so I'd assume putting something like

    CELERYBEAT_SCHEDULE = "{'key': 'value', 'another_key': 'another_value'}"
    

    should do the trick...