Delay in script

I have a script event that sends an xml message and writes the response as a string back to a tag. I modified this so that it
parses the response and writes only the data to a tag as an int. What I am hoping to do is add a scripted delay that I can adjust by ms or seconds right there in the script between the send of the message and the parse of the response. basically I am wanting to know how to do a ‘pause for x amount of time’ in the scripts…

import time
time.sleep(1)

is this useful? I am not on my dev computer but this looks elegantly simple…

Hi Tallfire,

I have tried using sleep() in Jython a couple of times and it unfortunately doesn’t often behave as you would like it to. I believe this is to do with threading. Heres an example:

from time import sleep print 'a' sleep(1) print 'b'
This will sleep for 1 second and then print a, b at the same time.

I would advise looking at invokeLater.

[code]def b():
import system
print ‘b’

def a(b):
import system
print ‘a’
system.util.invokeLater(b, 1000)

a(b)[/code]

This would do what you expect.

Dom

I agree with Dom - invokeLater() should help you in this situation.