Is there a way to Defuse a Firework from within one of the Firework's Firetasks?

I’d like to be able to defuse a firework from within itself. In other words, I’d like to have a firetask that looks something like this:


from fireworks import FiretaskBase, explicit_serialize, FWAction

@explicit_serialize
class TestFireTask(FiretaskBase):

    def run_task(self, fw_spec):
        defuse = fw_spec.get("defuse ", False)
        if defuse: 
             # CODE TO DEFUSE THE FIREWORK THAT THIS TASK IS A PART OF
        else: 
             return FWAction()

Is there a way to accomplish this?

You can’t DEFUSE the firework you are running since it is already running, therefore it’s not DEFUSED.

It’s possible you are looking for the exit=True option in the FWAction which will skip running the remaining FireTasks in that FireWork combined with defuse_children=True

Or, you may just want to raise an Exception which will cause the current FireWork to be FIZZLED and therefore pause everything.