← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #228913]: stopObserver() where to put in the class (Screen)

 

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

Description changed to:
I have written a python class for a screen, in it I have the below code
in __init__(self): definition

        self.screen.onAppear("PostingTrans.png", self.WaitWhilePostingTransaction)
        self.screen.observe(FOREVER, background=True)

I need this to be active until all the tests for the screen is finished.
Tests are in unit test class, and I create only one instance of the
screen class in the test class level and is used by all test methods.

Event is raised in each test and handler is called and works perfectly.

I haven't put he stopObserver() anywhere in the code. And I notice event
handler is being run in the background and slows my system.

I am running tests in an interactive mode (start tests, stop, start again, stop......) as I am still building all the tests. 
Multiple instances of the events are raised and STILL HANGING IN THE SYSTEM even after the tests are stopped. (Eclipse IDE)

I have decided to put the stopObserver() in __del__(self): definition.

Other option would be to create a close() method and call it explicitly
from the tearDownClass() method in unit test class.

What is the best approach?

Is my statement, Events are still hanging in the system true? Can
someone please explain on what is happening here?

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