Day #11 with Cloud Workflows: sleeping in a workflow

Guillaume Laforge
Google Cloud - Community
1 min readDec 22, 2020

Workflows are not necessarily instantaneous, and executions can span over a long period of time. Some steps may potentially launch asynchronous operations, which might take seconds or minutes to finish, but you are not notified when the process is over. So when you want for something to finish, for example before polling again to check the status of the async operation, you can introduce a sleep operation in your workflows.

To introduce a sleep operation , add a step in the workflow with a call to the built-in sleep operation:

- someSleep:
call: sys.sleep
args:
seconds: 10
- returnOutput:
return: We waited for 10 seconds!

A sleep operation takes a seconds argument, where you can specify the number of seconds to wait.

By combining conditional jumps and sleep operations, you can easily implement polling some resource or API at a regular interval, to double check that it completed.

Originally published at http://glaforge.appspot.com.

--

--

Guillaume Laforge
Google Cloud - Community

Developer Advocate for Google Cloud, Apache Groovy programming language co-founder, Java Champion