I find myself confronted with a gobject for the first time while trying to listening to dbus. I found this piece of code teaching me how to set up a main loop.
How can I listen for 'usb device inserted' events in Linux, in Python?
But what I need now is a way to stop it. The main loop has a quit function and I know how to call it from a keyboard interrupt exception. But how do I make it stop, when I put this main loop into a thread?
Or more general: What is the proper way to make this loop run independently, but also exit when the main function exits?
I appreciate your help.