multithreading - How to shut down gobject main loop properly in python? -
i find myself confronted gobject first time while trying listening dbus. found piece of code teaching me how set main loop.
how can listen 'usb device inserted' events in linux, in python?
but need way stop it. main loop has quit function , know how call keyboard interrupt exception. how make stop, when put main loop thread?
or more general: proper way make loop run independently, exit when main function exits?
i appreciate help.
don't know python in general should pass loop
variable calling thread (your main function) , loop.quit()
there when done.
to pass loop variable have 2 options:
- the easy way: initialize
loop
gobject.mainloop()
before forking, available both threads; - the hard way: pass value main thread after having initialized in loop thread.
an example (in c) of passing data between threads shown gcond documentation (push_data()
, pop_data()
).
Comments
Post a Comment