I'm writing a small Python debugger plugin for Gedit. It seems to run OK except for when debugging code which is itself Gtk.
The problem goes like this. Within the plugin code, when debugging starts, the debugger is started as a separate process via Python's multiprocessing modue:
multiprocessing.Process(target = run_dbg)
Inside this process, some script is debugged via Python's bdb module:
bdb.run('execfile("%s")' % script)
Now suppose the script being debugged contains this code:
Then, when the line is reached, Gedit crashes:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
gedit: ../../src/xcb_io.c:273: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Googling the error yielded many results. While helpful and informative, they seem to consist of suggestions for changes to the code causing the crash (i.e., call Gdk.init_threads() before Gtk.main(), and so forth). Since this is a debugger plugin, I cannot modify GEdit's code, nor the code of the script being debugged (requiring changing code so it can be debuged seems awkward). It seems the root of the problem is that the second, debugger, process, since it was created by the GEdit process, contains some Gtk somewhere. Is there some way to "get rid", in the second, debugger, process, of anything Gtk related? Something like completely_shut_down_anything_gtk() before starting bdb.run()?