06-22-2022 07:58 PM
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
Solved! Go to Solution.
06-23-2022 07:04 AM
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.
06-22-2022 11:12 PM
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
06-23-2022 06:47 AM
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.
06-23-2022 10:16 AM
The second one seems to be shorter and i was able to provide variables to sleep time instead of hardcoding the seconds. Thanks you!
06-23-2022 03:52 AM