# Signals


These Exceptions, when raised, are used to signal state changes when tasks or flows are running. Signals are used in TaskRunners and FlowRunners as a way of communicating the changes in states.

# ENDRUN

class

prefect.engine.signals.ENDRUN

(state)[source]

An ENDRUN exception is used to indicate that all state processing should stop. The pipeline result should be the state contained in the exception.

Args:

  • state (State): the state that should be used as the result of the Runner's run



# FAIL

class

prefect.engine.signals.FAIL

(message=None, *args, **kwargs)[source]

Indicates that a task failed.

Args:

  • message (Any, optional): Defaults to None. A message about the signal.
  • *args (Any, optional): additional arguments to pass to this Signal's associated state constructor
  • **kwargs (Any, optional): additional keyword arguments to pass to this Signal's associated state constructor



# LOOP

class

prefect.engine.signals.LOOP

(message=None, *args, **kwargs)[source]

Indicates that a task should loop with the provided result. Note that the result included in the LOOP signal will be available in Prefect context during the next iteration under the key "task_loop_result".

Args:

  • message (Any, optional): Defaults to None. A message about the signal.
  • *args (Any, optional): additional arguments to pass to this Signal's associated state constructor
  • **kwargs (Any, optional): additional keyword arguments to pass to this Signal's associated state constructor
Example:

import prefect
from prefect import task, Flow
from prefect.engine.signals import LOOP

@task
def accumulate(x: int) -> int:
    current = prefect.context.get("task_loop_result", x)
    if current < 100:
        # if current < 100, rerun this task with the task's loop result incremented
        # by 5
        raise LOOP(result=current + 5)
    return current

with Flow("Looper") as flow:
    output = accumulate(5)

flow_state = flow.run()
print(flow_state.result[output].result) # '100'



# TRIGGERFAIL

class

prefect.engine.signals.TRIGGERFAIL

(message=None, *args, **kwargs)[source]

Indicates that a task trigger failed.

Args:

  • message (Any, optional): Defaults to None. A message about the signal.
  • *args (Any, optional): additional arguments to pass to this Signal's associated state constructor
  • **kwargs (Any, optional): additional keyword arguments to pass to this Signal's associated state constructor



# VALIDATIONFAIL

class

prefect.engine.signals.VALIDATIONFAIL

(message=None, *args, **kwargs)[source]

Indicates that a task's result validation failed.

Args:

  • message (Any, optional): Defaults to None. A message about the signal.
  • *args (Any, optional): additional arguments to pass to this Signal's associated state constructor
  • **kwargs (Any, optional): additional keyword arguments to pass to this Signal's associated state constructor



# SUCCESS

class

prefect.engine.signals.SUCCESS

(message=None, *args, **kwargs)[source]

Indicates that a task succeeded.

Args:

  • message (Any, optional): Defaults to None. A message about the signal.
  • *args (Any, optional): additional arguments to pass to this Signal's associated state constructor
  • **kwargs (Any, optional): additional keyword arguments to pass to this Signal's associated state constructor



# RETRY

class

prefect.engine.signals.RETRY

(message=None, *args, **kwargs)[source]

Used to indicate that a task should be retried.

Args:

  • message (Any, optional): Defaults to None. A message about the signal.
  • *args (Any, optional): additional arguments to pass to this Signal's associated state constructor
  • **kwargs (Any, optional): additional keyword arguments to pass to this Signal's associated state constructor



# SKIP

class

prefect.engine.signals.SKIP

(message=None, *args, **kwargs)[source]

Indicates that a task was skipped. By default, downstream tasks will act as if skipped tasks succeeded.

Args:

  • message (Any, optional): Defaults to None. A message about the signal.
  • *args (Any, optional): additional arguments to pass to this Signal's associated state constructor
  • **kwargs (Any, optional): additional keyword arguments to pass to this Signal's associated state constructor



# PAUSE

class

prefect.engine.signals.PAUSE

(message=None, *args, **kwargs)[source]

Indicates that a task should not run and wait for manual execution.

Args:

  • message (Any, optional): Defaults to None. A message about the signal.
  • *args (Any, optional): additional arguments to pass to this Signal's associated state constructor
  • **kwargs (Any, optional): additional keyword arguments to pass to this Signal's associated state constructor



This documentation was auto-generated from commit 59ae220
on April 9, 2021 at 15:46 UTC