|
@@ -395,23 +395,19 @@ class Signature(dict):
|
|
|
other = maybe_unroll_group(other)
|
|
|
if isinstance(self, _chain):
|
|
|
|
|
|
- sig = self.clone()
|
|
|
- sig.tasks.append(other)
|
|
|
- return sig
|
|
|
+ return _chain(seq_concat_item(
|
|
|
+ self.unchain_tasks(), other), app=self._app)
|
|
|
|
|
|
return _chain(self, other, app=self.app)
|
|
|
|
|
|
if not isinstance(self, _chain) and isinstance(other, _chain):
|
|
|
|
|
|
- return _chain(
|
|
|
- seq_concat_seq((self,), other.tasks), app=self._app)
|
|
|
+ return _chain(seq_concat_seq(
|
|
|
+ (self,), other.unchain_tasks()), app=self._app)
|
|
|
elif isinstance(other, _chain):
|
|
|
|
|
|
- sig = self.clone()
|
|
|
- if isinstance(sig.tasks, tuple):
|
|
|
- sig.tasks = list(sig.tasks)
|
|
|
- sig.tasks.extend(other.tasks)
|
|
|
- return sig
|
|
|
+ return _chain(seq_concat_seq(
|
|
|
+ self.unchain_tasks(), other.unchain_tasks()), app=self._app)
|
|
|
elif isinstance(self, chord):
|
|
|
|
|
|
|
|
@@ -436,8 +432,8 @@ class Signature(dict):
|
|
|
return sig
|
|
|
else:
|
|
|
|
|
|
- return _chain(
|
|
|
- seq_concat_item(self.tasks, other), app=self._app)
|
|
|
+ return _chain(seq_concat_item(
|
|
|
+ self.unchain_tasks(), other), app=self._app)
|
|
|
|
|
|
return _chain(self, other, app=self._app)
|
|
|
return NotImplemented
|
|
@@ -557,6 +553,15 @@ class _chain(Signature):
|
|
|
]
|
|
|
return s
|
|
|
|
|
|
+ def unchain_tasks(self):
|
|
|
+
|
|
|
+
|
|
|
+ tasks = [t.clone() for t in self.tasks]
|
|
|
+ for sig in self.options.get('link_error', []):
|
|
|
+ for task in tasks:
|
|
|
+ task.link_error(sig)
|
|
|
+ return tasks
|
|
|
+
|
|
|
def apply_async(self, args=(), kwargs={}, **options):
|
|
|
|
|
|
app = self.app
|