Forum Discussion
viktor_n
4 years agoContributor II
Hi @brent.vanallen,
Regardless delaying, you can accomplish that with Script snap.
Here I use python
- At the top first
import time
module - Use
time.sleep(sec)
method
from com.snaplogic.scripting.language import ScriptHook
import time
class TransformScript(ScriptHook):
def __init__(self, input, output, error, log):
self.input = input
self.output = output
self.error = error
self.log = log
def execute(self):
self.log.info("Executing Transform script")
## Move time.sleep() here out of while loop if you want to wait only by the seconds you have specified not more.
while self.input.hasNext():
try:
inDoc = self.input.next()
## Here will wait for each document. That means if we have 5 documents at input and sleep is set for 10 seconds, it will wait 50 seconds till returns the output.
## In parameter specify the time in seconds. You can make it time dynamic if you specify the time out of the script snap and after that by getting the value with inDoc.get("field_Name")
time.sleep(10)
self.output.write(inDoc, inDoc)
except Exception as e:
errDoc = {
'error' : str(e)
}
self.log.error("Error in python script")
self.error.write(errDoc)
self.log.info("Script executed")
def cleanup(self):
self.log.info("Cleaning up")
hook = TransformScript(input, output, error, log)
Regards,
Viktor