[PyKDE] deadlock with QThread

Greg Fortune lists at gregfortune.com
Sun Aug 25 09:42:00 BST 2002


Phil,

We've managed to create a very nasty deadlock using the QThread class in an 
application we are developing.  I've attached some sample python code that 
demonstrates several cases in which QThread does work and one case in which 
it does not.  

Our application's code is closest to test case 4, but our code still does not 
work.  Regardless, test case 2 needs addressed and probably fixed :)  It is 
also possible that we just aren't using the QThread stuff correctly and in 
that case, I'd love to know what we've missed.

btw, the deadlock occurs when trying to import any module inside the 
QThread.run call.  Any function level imports in any code called by 
QThread.run lock up the thread and any imports directly in the QThread.run 
call lock up the thread.  

Oddly enough, imp.load_module() allows us to get around the bug, but only for 
standard python modules (perhaps because they are loaded as an .so??).  3rd 
party modules fail even in an imp.load_module() even though imp.find_module 
is successful.  Also, removing any function level imports also fixes the 
problems, but the imports that cause problems are not in our code.  They are 
actually in the MySQLdb module, but any module doing a function level import 
will cause the lock...

I'm still trying to determine what makes our code different from test case 4, 
which runs.  If I figure that out, I'll send another test case that does not 
work...  Until then, let me know what you find out with regards to test case 
2.

To execute test case 2, just run
./threadtest.py 2



Thanks for any help,


Greg Fortune
-------------- next part --------------
A non-text attachment was scrubbed...
Name: threadtest.tgz
Type: application/x-gzip
Size: 1942 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20020825/a2da52a8/threadtest.tgz


More information about the PyQt mailing list