[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:       Alan Ezust <alan.ezust () gmail ! com>
Date:       2015-01-07 22:33:03
Message-ID: CALy5K9rn5esyA-97=MzfN1GCCxOOXrLmHuYBmpY6LP_zMTMmVg () mail ! gmail ! com
[Download RAW message or body]

You can start up your own QEventLoop in the other thread...


On Wed, Jan 7, 2015 at 1:27 PM,  <Mathias.Born@gmx.de> wrote:
> 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
_______________________________________________
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