|
@@ -0,0 +1,59 @@
|
|
|
+"""myapp.py
|
|
|
+
|
|
|
+Usage::
|
|
|
+
|
|
|
+
|
|
|
+ (window1)$ python myapp.py worker -l info
|
|
|
+
|
|
|
+
|
|
|
+ (window2)$ python myapp.py beat -l info
|
|
|
+
|
|
|
+
|
|
|
+ (window2)$ python myapp.py beat -l debug
|
|
|
+
|
|
|
+
|
|
|
+ (window2) $ C_REMDEBUG=1 python myapp.py beat -l debug
|
|
|
+
|
|
|
+
|
|
|
+You can also specify the app to use with the `celery` command,
|
|
|
+using the `-A` / `--app` option::
|
|
|
+
|
|
|
+ $ celery -A myapp worker -l info
|
|
|
+
|
|
|
+With the `-A myproj` argument the program will search for an app
|
|
|
+instance in the module ``myproj``. You can also specify an explicit
|
|
|
+name using the fully qualified form::
|
|
|
+
|
|
|
+ $ celery -A myapp:app worker -l info
|
|
|
+
|
|
|
+"""
|
|
|
+from __future__ import absolute_import, unicode_literals, print_function
|
|
|
+
|
|
|
+from celery import Celery
|
|
|
+
|
|
|
+app = Celery(
|
|
|
+
|
|
|
+
|
|
|
+ 'myapp',
|
|
|
+ broker='amqp://guest@localhost//',
|
|
|
+
|
|
|
+
|
|
|
+)
|
|
|
+
|
|
|
+app.conf.timezone = 'UTC'
|
|
|
+
|
|
|
+@app.task
|
|
|
+def say(what):
|
|
|
+ print(what)
|
|
|
+
|
|
|
+
|
|
|
+@app.on_after_configure.connect
|
|
|
+def setup_periodic_tasks(sender, **kwargs):
|
|
|
+
|
|
|
+ sender.add_periodic_task(10.0, say.s('hello'), name='add every 10')
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ app.start()
|