decorators.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. from __future__ import absolute_import
  12. import warnings
  13. from . import task as _task
  14. from .exceptions import CDeprecationWarning
  15. warnings.warn(CDeprecationWarning("""
  16. The `celery.decorators` module and the magic keyword arguments
  17. are pending deprecation and will be deprecated in 2.4, then removed
  18. in 3.0.
  19. `task.request` should be used instead of magic keyword arguments,
  20. and `celery.task.task` used instead of `celery.decorators.task`.
  21. See the 2.2 Changelog for more information.
  22. """))
  23. def task(*args, **kwargs): # ✞
  24. kwargs.setdefault("accept_magic_kwargs", True)
  25. return _task.task(*args, **kwargs)
  26. def periodic_task(*args, **kwargs): # ✞
  27. kwargs.setdefault("accept_magic_kwargs", True)
  28. return _task.periodic_task(*args, **kwargs)