[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
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)
    # waits until GUI thread processes the posted event.
    condition.wait(mutex) # <-- stops everything!!

GUI thread processes events as follows:

def customEvent(self, event)
    # do something ...

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!?

More information about the PyQt mailing list