Browse Source

Adds subtask.clone()

Ask Solem 13 years ago
parent
commit
2bf8ef9a02
1 changed files with 6 additions and 0 deletions
  1. 6 0
      celery/task/sets.py

+ 6 - 0
celery/task/sets.py

@@ -69,6 +69,12 @@ class subtask(AttributeDict):
         options = dict(self.options, **options)
         return self.type.apply(args, kwargs, **options)
 
+    def clone(self, args=(), kwargs={}, **options):
+        return self.__class__(self.task,
+                              args=tuple(args) + tuple(self.args),
+                              kwargs=dict(self.kwargs, **kwargs),
+                              **dict(self.options, **options))
+
     def apply_async(self, args=(), kwargs={}, **options):
         """Apply this task asynchronously."""
         # For callbacks: extra args are prepended to the stored args.