I have a simple task that sleeps for a configured amount of time:
class SuspendConfig(BaseModel):
h: int = 0 # hours
m: int = 0 # minutes
s: int = 0 # seconds
@task
def suspend(config: SuspendConfig):
total_wait = (config.h * 3600) + (config.m * 60) + config.s
print(f"waiting for {total_wait} seconds")
time.sleep(total_wait)
However, this task often takes far longer when called in a flow:
09:56:57.257 | INFO | Task run 'suspend-0' - waiting for 900 seconds
11:21:27.748 | INFO | Task run 'suspend-0' - Finished in state Completed()
Any ideas as to why? The total time that the task runs doesn’t seem very correlated to the time I configure it to sleep for. I’ve read that there can be some variability in time.sleep(), but this seems like a lot. Is there a better way to add delays between tasks?
Thanks!