[PyKDE] Singleshot problems in QThreads on Windows.

Truls A. Tangstad kerfue+pykde at herocamp.org
Fri Aug 20 15:47:04 BST 2004

On Fri, Aug 20, 2004 at 11:59:50AM +0200, Truls A. Tangstad wrote:
> We're distributing a cross-platform application and having problems
> with QTimer.singleShot on windows.
> It seems that using QTimer from a QThread doesn't work, the callback
> is never run.
> The attached example shows the problem. On debian/linux both printing
> callbacks are run, but on windows only the first non-threaded one is
> called.
> Please let me know if I'm missing any restrictions on PyQt, threads,
> QTimer etc., or if the problem is with my code.
> Versions:
> Python 2.3.4
> Qt 3.3.3
> PyQt-commercial-snapshot-20040819
> sip-snapshot-20040819
> Windows XP Pro SP1

After hacking around with C++, it seems that the problem is with Qt in
windows, not PyQt.

The problem is now that we've created a workaround [1] for a
postEvent-bug which we cannot reproduce yet in a small example. The
workaround depends on being able to use QTimer.singleShot() to trigger
our own event handling in an object in the GUI-thread, which updates
the GUI and passing around the data within a thread-safe Queue.

For windows, all QTimer calls made in other threads than the
GUI-thread seems to be ignored, and using QApplication.postEvent
sporadically hangs the entire application.

So, what I'm wondering, is if there's a way to update the GUI with
state created by the worker-threads without using postEvent or QTimer
in the worker-threads? There must be some way to trigger calls in the
GUI-thread without these.

[1] - http://mats.imk.fraunhofer.de/pipermail/pykde/2004-August/008314.html

Truls A. Tangstad - <kerfue+pykde at h e r o c a m p.org>

More information about the PyQt mailing list