Launching A Truly Disjoint Process
d at davea.name
Sun Mar 11 22:34:41 CET 2012
On 03/11/2012 05:01 PM, Ami Tavory wrote:
> I'm encountering a problem using the multiprocessing module to create a
> process that is truly disjoint from the parent process: i.e., one that
> contains no "memory" of the parent process, nor any record in the parent
> process that it is its child. This originated in a pygtk problem, but I'll
> try to put down as little pygtk as possible - just enough to explain the
> problem (also, sorry, but I couldn't get an answer at the gtk forum).
> The code is a small python debugger front-end for GEdit. The plugin code,
> run from GEdit's process, uses
> <code>multiprocessing.Process(target = run_dbg)</code>
> to launch the debugger in a function in separate process. The debugger uses
> the bdb module like this:
> <code>bdb.run('execfile("%s")' % script)</code>.
> This seems to work fine, except if the script being debugged is itself a
> pygtk script. Specifically, if it contains the code
> then GEdit crashes with
> [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 this error yielded many results, but they all consisted of
> advice to change either the code launching the process (possibly compiling
> it differently), or change the launched process running gtk. It seems like
> gtk requires that a single thread run this. Unfortunately, in this case,
> the launching process is GEdit (whose code I cannot modify from a plugin),
> and the launched process essentially runs a hypothetical script that is
> being debugged (and whose code, therefore, is a given).
> OTOH, clearly it is possible to run more than a single gtk app
> concurrently from completely separate processes. Is there a way, therefore,
> to launch the second process, or have the launched process do something
> when it starts, so that the two processes should essentially be disjoint?
Why not try using bash as an intermediate executable? Have your first
python process invoke bash, giving it the arguments to in turn launch
the second python process.
If that won't work, then at least tell us some more of your
environment. What version of Python, what version of OS?
More information about the Python-list