myapp.py 685 B

1234567891011121314151617181920212223242526272829303132333435
  1. """myapp.py
  2. Usage:
  3. (window1)$ python myapp.py worker -l info
  4. (window2)$ python
  5. >>> from myapp import add
  6. >>> add.delay(16, 16).get()
  7. 32
  8. You can also specify the app to use with the `celery` command,
  9. using the `-A` / `--app` option::
  10. $ celery -A myapp worker -l info
  11. With the `-A myproj` argument the program will search for an app
  12. instance in the module ``myproj``. You can also specify an explicit
  13. name using the fully qualified form::
  14. $ celery -A myapp:app worker -l info
  15. """
  16. from celery import Celery
  17. app = Celery('myapp', broker='amqp://guest@localhost//')
  18. @app.task()
  19. def add(x, y):
  20. return x + y
  21. if __name__ == '__main__':
  22. app.start()