[PyKDE] QWaitCondition seems to cause deadlock

森田 慎一 shin1_morita at yahoo.co.jp
Tue May 18 19:00:00 BST 2004


Hi, this is shin.
It's my first time to post to this ml.

I'm a beginner of PyQt.
PyQt is very exciting!!
But I have a problem on my multi-thread script.

This script uses Qt thread API, and uses QMutex and
QWaitCondition to synchronize a GUI thread and a worker
thread.
When the worker thread calls QWaitCondition.wait(), GUI
thread also stops running.
It seems to be in deadlock state.

The worker's code is as follows:

def postAndWait(self)
    mutex.lock()
    QApplication::postEvent(receiver,
QCustomEvent(QEvent.User))
    # waits until GUI thread processes the posted event.
    condition.wait(mutex) # <-- stops everything!!
    mutex.unlock()

GUI thread processes events as follows:

def customEvent(self, event)
    mutex.lock()
    # do something ...
    condition.wakeAll()
    mutex.unlock()

I've been at a loss for a few days.
But today I found that Python Global Interpreter Lock
needs to be released and reacquired around blocking
operation according to Python C/API Reference Manual.
And I also found that QWaitCondition::wait()  in
qwaitcondition.sip has no annotation while
QThread::sleep() has /ReleaseGIL/ annotation.

I think that QWaitCondition::wait() must have /ReleaseGIL/
annotation, is that right?



__________________________________________________
Do You Yahoo!?
http://bb.yahoo.co.jp/




More information about the PyQt mailing list