pd.flow.suspend
and pd.flow.rerun
to pause a workflow and resume it later.
This is useful when you want to:
pd.flow.suspend
pd.flow.suspend
when you want to pause a workflow and proceed with the remaining steps only when manually approved or cancelled.
For example, you can suspend a workflow and send yourself a link to manually resume or cancel the rest of the workflow:
resume_url
and cancel_url
pd.flow.suspend
returns a cancel_url
and resume_url
that lets you cancel or resume paused executions. Since Pipedream pauses your workflow at the end of the step, you can pass these URLs to any external service before the workflow pauses. If that service accepts a callback URL, it can trigger the resume_url
when its work is complete.
These URLs are specific to a single execution of your workflow. While the workflow is paused, you can load these in your browser or send any HTTP request to them:
cancel_url
will cancel that executionresume_url
will resume that execution$resume_data
step export of the suspended step. For example, if you call pd.flow.suspend
within a step named code
, the $resume_data
export should contain the data sent in the resume_url
request:
pd.flow.suspend
will automatically cancel the workflow after 24 hours. You can set your own timeout (in milliseconds) as the first argument:
pd.flow.rerun
pd.flow.rerun
when you want to run a specific step of a workflow multiple times. This is useful when you need to start a job in an external API and poll for its completion, or have the service call back to the step and let you process the HTTP request within the step.
pd.flow.rerun
lets you rerun a specific step multiple times:
pd.flow.rerun
accepts the following arguments:
pd.flow.retry
:
context
to pd.flow.rerun
pd.context.run.context
contains the context
passed from the prior call to rerun
. This lets you pass data from one run to another. For example, if you call:
pd.context.run.context
will contain:
maxRetries
maxRetries
is 10.
When you exceed maxRetries
, the workflow proceeds to the next step. If you need to handle this case with an exception, raise
an Exception from the step:
pd.flow.suspend
or pd.flow.rerun
, it will not suspend the workflow, and you’ll see a message like the following:
Workflow execution canceled — this may be due to pd.flow.suspend()
usage (not supported in test)
These functions will only suspend and resume when run in production.
pd.flow.suspend
/ pd.flow.rerun
pd.flow.suspend
or pd.flow.rerun
. Only when workflows are resumed will compute time count toward credit usage.