[issue5908] I need to import the module in the same thread?

tyoc report at bugs.python.org
Sun May 3 03:20:52 CEST 2009


tyoc <zaz at alum.com> added the comment:

OK, here is a resume of the anterior.

I see clearly that it matter where I import the library (dont know if 
is a problem of the library or python). This time the thread doesnt 
end, will end when you hit CTRL+C in the terminal, for test this you 
need enabled accessibility.

Steps

1) run the code as is and see that it prints spot 0, 1 end is not wrote
2) uncomment the line of import pyatspi # import in the main thread and 
run again, see that it only print 0, it app is stuck inside 
pyatspi.Registry.registerEventListener(cb, 'focus')


[code start]---------------------------
import threading 
class thr(threading.Thread): 
    def __init__(self): 
        threading.Thread.__init__(self) 
#        import pyatspi # import in the main thread 
    def run(self): 
        def cb(eve): 
            print eve 
        import pyatspi # import here in the new thread 
        print 'spot 0' 
        pyatspi.Registry.registerEventListener(cb, 'focus') 
        print 'spot 1'
        pyatspi.Registry.start() 
        print 'End' 
  
t = thr() 
t.start() 
t.join() 
[code end]---------------------------



So at less for this library, it matter where you import the thing.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5908>
_______________________________________


More information about the Python-bugs-list mailing list