I'm writing an application using wxPython, that's supposed to start
new processes which should be able to create their own wxPython
windows. I'm using multiprocessing to start the processes, but my
application crashes when the new processes try to create new wxPython
windows.
When the processes are started from outside the wx app mainloop it
works as expected, but when the process is started within the
mainloop, the program crashes with the error messages:
python: Fatal IO error 0 (Success) on X server :0.0.
python: Fatal IO error 0 (Success) on X server :0.0.
python: ../../src/xcb_io.c:221: poll_for_event: Assertion `(((long)
(event_sequence) - (long) (dpy->request)) <= 0)' failed.
python: ../../src/xcb_io.c:221: poll_for_event: Assertion `(((long)
(event_sequence) - (long) (dpy->request)) <= 0)' failed.
Has anybody an idea how to solve this problem?
Here's a small script demonstrating what I'd like to do:
import wx
import multiprocessing
from wx.lib.mixins.inspection import InspectionMixin
## The pSysmon main application.
class MyApp(wx.App, InspectionMixin):
''' The wx application class.
'''
## The constructor
···
#
def __init__(self, redirect=False, filename=None,
useBestVisual=False, clearSigInt=True):
wx.App.__init__(self, redirect, filename, useBestVisual,
clearSigInt)
def onInit(self):
self.Init() # The widget inspection tool can be called
using CTRL+ALT+i
return True
class Test(wx.Frame):
def __init__(self, parent=None, id=wx.ID_ANY, title="Hallo",
size=(1000,600)):
wx.Frame.__init__(self, parent=parent, id=id, title=title,
pos=wx.DefaultPosition, style=wx.DEFAULT_FRAME_STYLE)
self.SetMinSize(size)
def startWxProcess():
app = MyApp()
dlg = Test()
dlg.Show()
p = multiprocessing.Process(target=startChildWxProcess)
p.start()
app.MainLoop()
def startChildWxProcess():
app = MyApp()
dlg = Test()
dlg.Show()
app.MainLoop()
if __name__ == '__main__':
# Start the first process.
p = multiprocessing.Process(target=startWxProcess)
p.start()
# Start the second process.
p1 = multiprocessing.Process(target=startWxProcess)
p1.start()