Skip to content

TIMER

Download Flojoy Studio to try this app
Sleep (pause program execution) for a specified number of seconds. Params: sleep_time : float number of seconds to sleep Returns: out : Optional[DataContainer] Returns the input if one was passed in.
Python Code
from flojoy import flojoy, DataContainer
from flojoy.job_result_builder import JobResultBuilder
import time
from typing import Optional, cast


@flojoy
def TIMER(
    default: Optional[DataContainer] = None,
    sleep_time: float = 0,
) -> DataContainer:
    """Sleep (pause program execution) for a specified number of seconds.

    Parameters
    ----------
    sleep_time : float
        number of seconds to sleep

    Returns
    -------
    Optional[DataContainer]
        Returns the input if one was passed in.
    """

    time.sleep(sleep_time)
    result = cast(
        DataContainer,
        JobResultBuilder().from_inputs([default] if default else []).build(),
    )

    return result

Find this Flojoy Block on GitHub

Example App

Having problems with this example app? Join our Discord community and we will help you out!
React Flow mini map

In this example the TIMER node sleeps for number of seconds passed to its parameter sleep_time which is 5 in this case before executing other nodes CONSTANT and END.