I'm running MooEdit 1.1.93 on Ubuntu 12.04, and need to run a thread from a Python plug‑in (a kind of HTTP server). The thread makes no attempt to access the GTK GUI, and just needs to access data from MooEdit and receive data from somewhere.
Creating a threading.Thread and then invoking run, seems not working. I've tried to start it at plug‑in initialization as much as on the application's started event handler, but neither works, and the thread seems not be running. It runs fine from outside of MooEdit.
I believe this is somewhat possible, as MooEdit is able to run external commands for the purpose of user tools.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I could not run a threading.Thread while gtk.main is running, but I could learn about an alternative way to have a server running inside of MooEdit (just tested standalone so far, not already from inside of MooEdit).
Hopefully, this solution is probably an alternative to near to all cases where one believe to only need a thread, so although this is not about how to create the thread mentioned in the first message, this is as much good.
The solution is to use glib.io_add_watch (which by the way, only works from a GTK main thread). As attachment, the sample Python program I successfully tested (comes with comments), on Ubuntu 12.04 at least (should be OK on Windows too).
Hi people,
I'm running MooEdit 1.1.93 on Ubuntu 12.04, and need to run a thread from a Python plug‑in (a kind of HTTP server). The thread makes no attempt to access the GTK GUI, and just needs to access data from MooEdit and receive data from somewhere.
Creating a
threading.Thread
and then invokingrun
, seems not working. I've tried to start it at plug‑in initialization as much as on the application'sstarted
event handler, but neither works, and the thread seems not be running. It runs fine from outside of MooEdit.I believe this is somewhat possible, as MooEdit is able to run external commands for the purpose of user tools.
I said:
Finally seems this does not use threads and uses
g_spawn_async_with_pipes
instead and I can't use this solution.I could not run a
threading.Thread
whilegtk.main
is running, but I could learn about an alternative way to have a server running inside of MooEdit (just tested standalone so far, not already from inside of MooEdit).Hopefully, this solution is probably an alternative to near to all cases where one believe to only need a thread, so although this is not about how to create the thread mentioned in the first message, this is as much good.
The solution is to use
glib.io_add_watch
(which by the way, only works from a GTK main thread). As attachment, the sample Python program I successfully tested (comes with comments), on Ubuntu 12.04 at least (should be OK on Windows too).One may also have a look at: http://d.hatena.ne.jp/biochem_fan/20130808
Have a nice day :-p
Last edit: Hibou57 2014-02-13