'How to skip a task in celery chain based on a flag

Is it possible to skip a task in celery chain, let's say I have the task chained like below

chain(task1.si(), task2.si(), task3.si()).apply_async()

Here I want to skip task2 from execution based on a flag, so only task1 and task3 should execute.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source