running pyqt app event loop in secondary thread, using (Py)Qt6.5

Jeremy Katz jkatz at volexity.com
Fri Sep 22 23:36:28 BST 2023



On 9/22/23 10:53, Stefan Seefeld wrote:

> 
>      > 2. rather than just "yielding" to the test function, yield the
>      > application object (so the test function can interact with it). No
>      > matter when you click the "quit" button, the result is the same
>     as in 1.
>      >
>      > 3. call `h.app.quit()` after he `yield` (i.e. as soon as the test
>      > function completes). Result: the application becomes
>     unresponsive, but
>      > doesn't stop
> 
>     2 and possibly 3 sound like more instances of a wrong thread situation.
> 
> 
> The call to `quit()` is documented to be thread-safe, so it should work 
> fine even when made programmatically from other threads than the one 
> running the event loop.
> Is this potentially an issue with PyQt not routing the signal correctly ?

I went searching for Qt 6 references to QCoreApplication.quit, as this 
has changed from Qt 5. Qt 5 makes no promises.
https://doc.qt.io/qt-6/qcoreapplication.html#quit says:
Thread-safety note: this function may be called from any thread to 
thread-safely cause the currently-running main application loop to exit. 
However, thread-safety is not guaranteed if the QCoreApplication object 
is being destroyed at the same time.

Unless the application is setting up a connection, there is no signal 
routing involved.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x67F18D5A76753BBB.asc
Type: application/pgp-keys
Size: 3147 bytes
Desc: OpenPGP public key
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230922/fb8905af/attachment-0001.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230922/fb8905af/attachment-0001.sig>


More information about the PyQt mailing list