← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #223584]: observe(background=True) works after stopping script, is this correct?

 

Question #223584 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/223584

Filin8 posted a new comment:
my tip above is wrong, there is some more problems:
- if i press "Ctrl+Alt+c", script stopped, but background observers stay running.
- if scripts stopped with exeption, same thing are happens. 

to finally workaround this, i use "Ctrl+Alt+x" and make try .. exept on
whole script:

def stopObservers():
    print "stopping all observers now"
    reg1.stopObserver()
    reg2.stopObserver()

def catchBreak (event):
    print "stop script now"
    stopObservers()
    #sys.exit()
    type ('c', KeyModifier.ALT+KeyModifier.SHIFT)
Env.addHotkey('x', KeyModifier.ALT+KeyModifier.SHIFT, catchBreak)

try:
    #
    #...
    #
except:
    print ("exception")
    stopObservers()
    raise

questions:
1) is there a way to stop all running oblervers in all regions with one command? without defining it for each region?
2) if i use sys.exit() inside def or inside try..except, it makes IDE silently closed without any warnings. and i lost any unsaved changes in another scripts. (that why i use "type ('c', KeyModifier.ALT+KeyModifier.SHIFT)" instead)
bug?

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.