TIMER
The TIMER node sleeps for a specified number of seconds.Params:sleep_time : floatnumber of seconds to sleepReturns:out : Optional[DataContainer]Returns the input if one was passed in.
Python Code
from flojoy import flojoy, DataContainer, DefaultParams
from flojoy.utils import PlotlyJSONEncoder
from flojoy.job_result_builder import JobResultBuilder
import plotly.graph_objects as go
import time
import json
from typing import Optional, cast
@flojoy
def TIMER(
default: Optional[DataContainer] = None,
sleep_time: float = 0,
) -> DataContainer:
"""The TIMER node sleeps 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
Example
Having problem with this example app? Join our Discord community and we will help you out!
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
.