← Back to team overview

sikuli-driver team mailing list archive

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

 

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

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 its 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.