[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] How to get Qt signals delivered to a pure python thread.
From:       Mathias.Born () gmx ! de
Date:       2015-01-07 21:27:02
Message-ID: 1918134282.20150107222702 () gmx ! de
[Download RAW message or body]

On 07.01.2015, 16:11:36 Ilya Kulakov wrote:
> I have a python thread that mainly serves a network connection. In
> this thread (due to the logic/architecture of my app) I need connect
> to a slot of QApplication clipboard.
> Something straightforward like connect does not work because my
> thread does not have a Qt event loop. However if I connect with a
> DirectConnect, I'll get my callback called, but sometimes it simply
> stops to work: no events are delivered.

> Is there any utility classes in PyQt to subscribe to Qt events from non-Qt threads?

I can't answer your last question, but I'd like to comment about the rest.

http://doc.qt.io/qt-5/qt.html#ConnectionType-enum
clearly describes "DirectConnect" as:

"The slot is invoked immediately when the signal is emitted.
The slot is executed in the signalling thread."

This means your callback is executed in the main thread. I suspect
it accesses objects of the other python thread without proper
synchronization. This may cause subtle multi-threading bugs, where
things "sometimes" happen.

Best Regards,
Mathias




_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic