[PyQt] multiprocessing with QApplication

Luke Campagnola lcampagn at email.unc.edu
Mon Jun 11 16:44:27 BST 2012


Howdy,

I am trying to use multiprocessing in a PyQt application to spawn an extra
process with its own GUI. The problem I am running into is that the child
process seems to be instantiated with a broken QApplication instance that
causes the child to crash. If I understand multiprocessing correctly, child
processes will inherit some resources from the parent process (file
handles, for example) and I suspect this is leading the child process to
believe it already has a QApplication.

I have attached a simple script that demonstrates this problem. If the
child process is spawned before the parent process instantiates its
QApplication, then everything works as expected. If the parent QApplication
is created before spawning the child process, then we see that  1) the
child thinks it already has a QApplication and 2) the program crashes,
presumably because the QApplication was never properly instantiated by the
child. (If I try creating a new QApplication in the child then the process
simply hangs or has other erratic behavior, which is usually the result of
creating more than one QApplication).

Any experience / suggestions?

Thanks,
Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120611/d4b1eda6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mptest.py
Type: application/octet-stream
Size: 779 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120611/d4b1eda6/attachment.obj>


More information about the PyQt mailing list