| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | """myapp.pyUsage::   # The worker service reacts to messages by executing tasks.   (window1)$ python myapp.py worker -l info   # The beat service sends messages at scheduled intervals.   (window2)$ python myapp.py beat -l info   # XXX To diagnose problems use -l debug:   (window2)$ python myapp.py beat -l debug   # XXX XXX To diagnose calculated runtimes use C_REMDEBUG envvar:   (window2) $ C_REMDEBUG=1 python myapp.py beat -l debugYou can also specify the app to use with the `celery` command,using the `-A` / `--app` option::    $ celery -A myapp worker -l infoWith the `-A myproj` argument the program will search for an appinstance in the module ``myproj``.  You can also specify an explicitname using the fully qualified form::    $ celery -A myapp:app worker -l info"""from __future__ import absolute_import, unicode_literals, print_functionfrom celery import Celeryapp = Celery(    # XXX The below 'myapp' is the name of this module, for generating    # task names when executed as __main__.    'myapp',    broker='amqp://guest@localhost//',    # ## add result backend here if needed.    # backend='rpc')app.conf.timezone = 'UTC'@app.taskdef say(what):    print(what)@app.on_after_configure.connectdef setup_periodic_tasks(sender, **kwargs):    # Calls say('hello') every 10 seconds.    sender.add_periodic_task(10.0, say.s('hello'), name='add every 10')    # See periodic tasks user guide for more examples:    # http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.htmlif __name__ == '__main__':    app.start()
 |