Record the nesting level across successive task replacements.
(self, replacements, nesting=None)
| 163 | |
| 164 | @shared_task(bind=True) |
| 165 | def record_replaced_task_nesting(self, replacements, nesting=None): |
| 166 | """Record the nesting level across successive task replacements.""" |
| 167 | if nesting is None: |
| 168 | nesting = [] |
| 169 | nesting.append(self.request.replaced_task_nesting) |
| 170 | if replacements: |
| 171 | replacement = record_replaced_task_nesting.s(replacements - 1, nesting) |
| 172 | # Keep the caller's result queue when using the RPC backend. |
| 173 | return self.replace(replacement.set(reply_to=self.request.reply_to)) |
| 174 | return nesting |
| 175 | |
| 176 | |
| 177 | @shared_task(bind=True) |