Forum Discussion

arvindnsn's avatar
arvindnsn
Contributor
4 years ago
Solved

Delay or wait process

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 o...
  • bojanvelevski's avatar
    bojanvelevski
    4 years ago

    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.