cancel
Showing results for 
Search instead for 
Did you mean: 

Delay or wait process

arvindnsn
Contributor

Hello,

I have a requirement where a snap has to wait for n amount of seconds before it executes. The n amount of seconds varies based on the output of the previous snap. How do I carry the output of a variable from a previous snap and pass it as the number of seconds to wait for the following snap.

Thanks
Aravind N

1 ACCEPTED SOLUTION

Yes there is. In the incoming object itself, map a field called “time” for example. Than, in the script, right after the
in_doc=self.input.next() line, add the following one:

sleep_time = in_doc.get('time')

sleep_time is your variable you can use to dynamically change the waiting time for every document. Meaning you need to change the sleep function to:

time.sleep(sleep_time)

You can manipulate the waiting time by changing the “time” value in the mapper before the script, or even pass that value from a parameter.

View solution in original post

7 REPLIES 7

JensDeveloper
Contributor II

Hi @arvindnsn

I don’t think there is a snap cabaple of doing that but You can find more info about a script some peoplse use on these two topics.

Regards

Is there a way to send a variable from the previous snap to the script Snap instead of hardcoding the seconds to sleep.

below script says time.sleep(120), instead can we pass a parameter like time.sleep($sleep_time), where $sleep_time carries the number of seconds from the previous mapper.

image

The second one seems to be shorter and i was able to provide variables to sleep time instead of hardcoding the seconds. Thanks you!

bojanvelevski
Valued Contributor