Callback when an observation timeout

Asked by horiel on 2019-07-18

Hello,
I am using the 1.1.x Sikuli version

when doing:
def changed(event):
        print "something changed in ", event.region

my_region.onChange(50, changed)
my_region.observeInBackground(10)

Is there a way to have a callback after 10 seconds if the observation timeout ? Something like:
my_region.onTimeOut(callback)

Thanks a lot

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
horiel
Solved:
2019-07-19
Last query:
2019-07-19
Last reply:
2019-07-19
RaiMan (raimund-hocke) said : #1

If there is nothing else to do during the onChange-observation, then just use the normal observe() which just waits for the success or finally the timeout.

success = false

def changed(event):
        global success
        success = true
        print "something changed in ", event.region

my_region.onChange(50, changed)
my_region.observe(10)
if success:
  pass # do something
else:
  pass # do something else

horiel (alexis-jacquelin) said : #2

thx Raiman for the response, I will do that.