decorators.py 1001 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. """
  3. celery.decorators✞
  4. ==================
  5. Deprecated decorators, use `celery.task.task`,
  6. and `celery.task.periodic_task` instead.
  7. The new decorators does not support magic keyword arguments.
  8. :copyright: (c) 2009 - 2011 by Ask Solem.
  9. :license: BSD, see LICENSE for more details.
  10. """
  11. import warnings
  12. from celery import task as _task
  13. warnings.warn(PendingDeprecationWarning("""
  14. The `celery.decorators` module and the magic keyword arguments
  15. are pending deprecation and will be deprecated in 2.4, then removed
  16. in 3.0.
  17. `task.request` should be used instead of magic keyword arguments,
  18. and `celery.task.task` used instead of `celery.decorators.task`.
  19. See the 2.2 Changelog for more information.
  20. """))
  21. def task(*args, **kwargs): # ✞
  22. kwargs.setdefault("accept_magic_kwargs", True)
  23. return _task.task(*args, **kwargs)
  24. def periodic_task(*args, **kwargs): # ✞
  25. kwargs.setdefault("accept_magic_kwargs", True)
  26. return _task.periodic_task(*args, **kwargs)