'Python GLib.MainLoop.run in a process
In a standalone Python script, I have a functioning GLib mainloop.
# myloop.py
import gobject as GLib
def main():
mainloop = GLib.MainLoop()
# do some DBus related stuffs
mainloop.run()
if __name__ == '__main__':
main()
I now need to run this from another Python project,
where multiple processes are used to implement different features.
from multiprocessing import Process
from myloop import main as myloop_main
def do something():
# do somethng else
if __name__ == '__main__':
something_proc = Process(target = do_something)
myloop_proc = Process(target = myloop_main)
something_proc.start()
myloop_proc.start()
something_proc.join()
myloop_proc.join()
This runs without error, but the mainloop is not really running
and the feature implemented in the mainloop is not working.
How to run the GLib's mainloop in a process?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
