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

    Status: Open => Answered

RaiMan proposed the following answer:
Currently Sikuli does not have a locking mechanism, to hinder handlers
belonging to  different background observes  from running in parallel.
It is not only the mouse/keyboard problem, but already the usage of
globals (like priority) is critical, since concurrent access to these
global resources is not thread safe (the thread's time window might end
between checking and setting a global).

Since you are working on the Jython level, you might try to use Pythons
thread module's locking mechanism:

in main workflow:

def onAppear(event):
    test = ABC()
    global priority, myLock
    myLock.acquire() 
    priority += 1
    print "Captured the event", priority
    if priority == 1:
        test.add()
    elif priority == 2:
        test.subtract()
    else:
        test.multiply()
    myLock.release() 
    
myLock = thread.allocate_lock()
test = ABC()
test.waitForEvent()

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

_______________________________________________
Mailing list: https://launchpad.net/~sikuli-driver
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~sikuli-driver
More help   : https://help.launchpad.net/ListHelp

Reply via email to