[PyQt] Qthread segmentation fault

Brian Kelley kelley at eyesopen.com
Tue Dec 9 13:50:27 GMT 2008

There was a similar message just a a day or so ago.  For this particular application, you don't need threads.  However, you probably don't want that answer.

It looks like you are creating the socket in one thread and using it in both the main and worker threads.  I believe you should be only using the socket in the worker thread and then communicating back to the main thread and you should never directly or indirectly use a QWidget based object from the thread.

>From the docs: http://doc.trolltech.com/4.4/qthread.html

Note, however, that it is not possible to use any widget classes in the thread.

My suggestion is to (1) don't use threads or (2) have the socket only in the qthread class and communicate your data back to the gui classes using signals or through another mechanism.

Quite honestly the IO of your program is small enough you could just use a QTimer to poll the socket periodically.  You would probably want to have some type of sleep in your thread anyway since as written this would consume 100% cpu :)

Brian Kelley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20081209/5caa1b61/attachment.html

More information about the PyQt mailing list