瀏覽代碼

Removes deprecated TaskSet invocation (should have been removed in 2.4)

Ask Solem 13 年之前
父節點
當前提交
a98a33b438
共有 2 個文件被更改,包括 6 次插入75 次删除
  1. 6 58
      celery/task/sets.py
  2. 0 17
      celery/tests/test_task/test_task_sets.py

+ 6 - 58
celery/task/sets.py

@@ -12,37 +12,12 @@
 from __future__ import absolute_import
 from __future__ import with_statement
 
-import warnings
-
 from .. import registry
 from ..app import app_or_default
 from ..datastructures import AttributeDict
-from ..exceptions import CDeprecationWarning
 from ..utils import cached_property, reprcall, uuid
 from ..utils.compat import UserList
 
-TASKSET_DEPRECATION_TEXT = """\
-Using this invocation of TaskSet is deprecated and will be removed
-in Celery v2.4!
-
-TaskSets now supports multiple types of tasks, the API has to reflect
-this so the syntax has been changed to:
-
-    from celery.task import TaskSet
-
-    ts = TaskSet(tasks=[
-            %(cls)s.subtask(args1, kwargs1, options1),
-            %(cls)s.subtask(args2, kwargs2, options2),
-            ...
-            %(cls)s.subtask(argsN, kwargsN, optionsN),
-    ])
-
-    result = ts.apply_async()
-
-Thank you for your patience!
-
-"""
-
 
 class subtask(AttributeDict):
     """Class that wraps the arguments and execution options
@@ -136,28 +111,12 @@ class TaskSet(UserList):
         >>> list_of_return_values = taskset_result.join()  # *expensive*
 
     """
-    _task = None                # compat
-    _task_name = None           # compat
-
     #: Total number of subtasks in this set.
     total = None
 
-    def __init__(self, task=None, tasks=None, app=None, Publisher=None):
+    def __init__(self, tasks=None, app=None, Publisher=None):
         self.app = app_or_default(app)
-        if task is not None:
-            if hasattr(task, "__iter__"):
-                tasks = [maybe_subtask(t) for t in task]
-            else:
-                # Previously TaskSet only supported applying one kind of task.
-                # the signature then was TaskSet(task, arglist),
-                # so convert the arguments to subtasks'.
-                tasks = [subtask(task, *arglist) for arglist in tasks]
-                task = self._task = registry.tasks[task.name]
-                self._task_name = task.name
-                warnings.warn(TASKSET_DEPRECATION_TEXT % {
-                                "cls": task.__class__.__name__},
-                              CDeprecationWarning)
-        self.data = list(tasks or [])
+        self.data = [maybe_subtask(t) for t in tasks or []]
         self.total = len(self.tasks)
         self.Publisher = Publisher or self.app.amqp.TaskPublisher
 
@@ -192,21 +151,10 @@ class TaskSet(UserList):
     def _sync_results(self, taskset_id):
         return [task.apply(taskset_id=taskset_id) for task in self.tasks]
 
-    @property
-    def tasks(self):
+    def _get_tasks(self):
         return self.data
 
-    @property
-    def task(self):
-        warnings.warn(
-            "TaskSet.task is deprecated and will be removed in 1.4",
-            CDeprecationWarning)
-        return self._task
-
-    @property
-    def task_name(self):
-        warnings.warn(
-            "TaskSet.task_name is deprecated and will be removed in 1.4",
-            CDeprecationWarning)
-        return self._task_name
+    def _set_tasks(self, tasks):
+        self.data = tasks
+    tasks = property(_get_tasks, _set_tasks)
 group = TaskSet

+ 0 - 17
celery/tests/test_task/test_task_sets.py

@@ -3,9 +3,7 @@ from __future__ import with_statement
 
 import anyjson
 
-from celery import registry
 from celery.app import app_or_default
-from celery.exceptions import CDeprecationWarning
 from celery.task import Task
 from celery.task.sets import subtask, TaskSet
 
@@ -102,21 +100,6 @@ class test_subtask(Case):
 
 class test_TaskSet(Case):
 
-    def test_interface__compat(self):
-        with self.assertWarnsRegex(CDeprecationWarning,
-                r'Using this invocation of TaskSet is deprecated'):
-            ts = TaskSet(MockTask, [[(2, 2)], [(4, 4)], [(8, 8)]])
-            self.assertListEqual(ts.tasks,
-                                 [MockTask.subtask((i, i))
-                                    for i in (2, 4, 8)])
-        with self.assertWarnsRegex(CDeprecationWarning,
-                r'TaskSet.task is deprecated'):
-            self.assertEqual(ts.task, registry.tasks[MockTask.name])
-
-        with self.assertWarnsRegex(CDeprecationWarning,
-                r'TaskSet.task_name is deprecated'):
-            self.assertEqual(ts.task_name, MockTask.name)
-
     def test_task_arg_can_be_iterable__compat(self):
         ts = TaskSet([MockTask.subtask((i, i))
                         for i in (2, 4, 8)])