decorators.py 1.1 KB

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