[PyQt] deadlock when using new style signal / slots
Erik Janssens
Erik.Janssens at conceptive.be
Fri Aug 27 20:56:14 BST 2010
Hi,
Another issue popped up when porting our code to
new style signal slots.
it appears the deadlock occurs when one thread is
emitting using a pyqtSignal object, while another
thread is connecting the same pyqtSignal object to
a slot, this is the pseudocode for the connection :
class(...):
def __init__(...):
self.rsh.entity_update_signal.connect( self.handle_entity_update )
@QtCore.pyqtSlot( object, object )
def handle_entity_update( self, sender, entity ):
...
Are these operations supposed to be thread safe or am
I missing something ?
Thanks a lot,
Erik
PS 1 : using pyqt 4.7.2 on Ubuntu
PS 2 : stack traces
A debugging session in GDB shows both threads waiting :
The thread that is making the connection :
#0 0x0012d422 in __kernel_vsyscall ()
#1 0x00138015 in pthread_cond_wait@@GLIBC_2.3.2 ()
from /lib/tls/i686/cmov/libpthread.so.0
#2 0x006a48c2 in QMutexPrivate::wait (this=0x8b652b0, timeout=-1) at
thread/qmutex_unix.cpp:84
#3 0x006a0072 in QMutex::lock (this=0x8b63768) at thread/qmutex.cpp:205
#4 0x007b9dec in QOrderedMutexLocker::relock (sender=0x8362030,
signal_index=2, receiver=0xb36795f0, method_index=27, type=0, types=0x0)
at ../../include/QtCore/private/../../../src/corelib/thread/qorderedmutexlocker_p.h:82
#5 QOrderedMutexLocker (sender=0x8362030, signal_index=2,
receiver=0xb36795f0, method_index=27, type=0, types=0x0)
at ../../include/QtCore/private/../../../src/corelib/thread/qorderedmutexlocker_p.h:72
#6 QMetaObjectPrivate::connect (sender=0x8362030, signal_index=2,
receiver=0xb36795f0, method_index=27, type=0, types=0x0) at
kernel/qobject.cpp:2908
#7 0x007ba3b2 in QObject::connect (sender=0x8362030, signal=0x886dff0
"2entity_update_signal(PyQt_PyObject,PyQt_PyObject)",
receiver=0xb36795f0, method=0xb388b018
"1handle_entity_update(PyQt_PyObject,PyQt_PyObject)",
type=Qt::AutoConnection) at kernel/qobject.cpp:2607
#8 0x005a2f46 in ?? ()
from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#9 0x005a39e6 in ?? ()
from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#10 0x080e0a21 in call_function (f=warning: can't find linker symbol for
virtual table for `(null)' value
warning: can't find linker symbol for virtual table for `(null)' value
Frame 0xb4cb6474, for file camelot/view/proxy/collection_proxy.py, line
228, in __init__
The thread that is emitting the signal :
#1 0x0013a245 in sem_wait@@GLIBC_2.1 ()
from /lib/tls/i686/cmov/libpthread.so.0
#2 0x0810abe8 in PyThread_acquire_lock (lock=0x8322d18, waitflag=1)
at ../Python/thread_pthread.h:349
#3 0x080dbe9c in PyEval_RestoreThread (tstate=0x8878c98)
at ../Python/ceval.c:353
#4 0x080fdc78 in PyGILState_Ensure () at ../Python/pystate.c:592
#5 0x005a6a06 in ?? ()
from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#6 0x005a295b in ?? ()
from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#7 0x007b23d8 in QMetaType::construct (type=256, copy=0xb6abdbc0) at
kernel/qmetatype.cpp:1116
#8 0x007b91cc in queued_activate (sender=<value optimized out>,
signal=<value optimized out>, c=0xba47c38, argv=0xb515ef98,
semaphore=0x0) at kernel/qobject.cpp:3166
#9 0x007bb2b1 in QMetaObject::activate (sender=0x8362030, m=0x8890de8,
local_signal_index=0, argv=0xb515ef98) at kernel/qobject.cpp:3266
#10 0x007bb9ea in QMetaObject::activate (sender=0x8362030,
signal_index=4, argv=0xb515ef98) at kernel/qobject.cpp:3346
#11 0x007bba2b in QMetaObject::activate (sender=0x8362030,
from_signal_index=4, to_signal_index=4, argv=0xb515ef98) at
kernel/qobject.cpp:3204
#12 0x005a9da4 in ?? ()
from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#13 0x005a2aec in ?? ()
from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so
#14 0x080e0a21 in call_function (f=warning: can't find linker symbol for
virtual table for `(null)' value
More information about the PyQt
mailing list