且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python 3.4:Windows上的PyQt:仅在某些计算机上退出时崩溃

更新时间:2022-12-24 16:59:08

原来全部强>我用来与这个程序崩溃的问题是因为QThread(在Windows上)。我知道的所有用户在Windows上使用QThread有类似的问题,并且由于某种原因没有人修复它。



在Python上避免QThread。它是完全无用的,更有害的,而不是有用的。我现在去了 multiprocessing 。它更好,不受GIL影响。


I have a Python program that I packaged with cx_freeze to make executable. The program is strictly a desktop program for data acquisition. It works fine and exits fine on every computer, but on one desktop of one of our collaborators with Windows 7 on it, it crashes only on exit (I emphasize that no pythonic errors are given. Just a low-level crash with zero information about it). Simply starting and exiting the program crashes it!

I got the guy to create a memory dump for me, and he did. The weird part is the following: Creating a memory dump out of this and analyzing it with WinDbg gives the following chain of errors:

STACK_TEXT:  
WARNING: Stack unwind information not available. Following frames may be wrong.
0020f940 5c51b34e 5c7bd640 9d7a3385 03c93748 QtCore4!QHashData::free_helper+0x26
0020f974 76e314bd 00b30000 00000000 03e0c4c0 QtGui4!QGestureRecognizer::reset+0x1f9e
0020f9a0 5c51c968 03c93748 5d3608c2 00000001 kernel32!HeapFree+0x14
0020f9a8 5d3608c2 00000001 03c93748 03891250 QtGui4!QGestureRecognizer::reset+0x35b8
0020f9c0 5d3627b5 9d0dae1c 03891250 03cac0a0 QtCore4!QObjectPrivate::deleteChildren+0x72
00000000 00000000 00000000 00000000 00000000 QtCore4!QObject::~QObject+0x3e5

Now what surprises me is that a complaint from QGestureRecognizer (which is a part of QtGUI apparently) is given! But why? I don't use any touch capabilities! The modules I use are: QtCore and QtGUI. Where is this coming from? Can I, like, force disable everything related to that class: QGestureRecognizer? What would you do in this case?

Update:

This issue seems to happen ONLY on Windows 7 computers. It was tested on 2 computers with Windows 7 and the same crash happened.

It turned out that ALL the problems I used to have with this program crashing were because of QThread (on Windows). All the users I know of that used QThread on Windows got similar issues, and for some reason no one is fixing it.

Avoid QThread on Python. It's completely useless and more harmful than useful. I went now to multiprocessing. It's much better and isn't affected by GIL.