running pyqt app event loop in secondary thread, using (Py)Qt6.5
Stefan Seefeld
stefan at seefeld.name
Fri Sep 22 17:35:52 BST 2023
Hello,
I'm trying to establish a Python test methodology whereby a QApplication is
launched (and its event loop executed) in a secondary thread, while the
primary thread performs some "test scenario".
Summary: I'm unable to set this up, and it isn't clear why this isn't
working.
Details: please consider the attached test file (executed with `pytest -vs
qt-minimal-test,py`).
In this minimal test case, the actual test function body is empty. A
"fixture" function is used to set up the system, i.e. launch a thread to
construct the application showing only a "quit" button.
Consider these cases:
0. run the above command, wait for the test passing being reported on the
console, then click the "quit" button. This appears to be working as
expected.
1. run the above command, but click the "quit" button immediately. Thus
results in the error message `QObject::killTimer: Timers cannot be stopped
from another thread`,
followed by a segmentation fault
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
Any idea why the above happens ?
Many thanks for any help you can offer !
--
...ich hab' noch einen Koffer in Berlin...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230922/ffd7f907/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt-minimal-test.py
Type: text/x-python
Size: 1318 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230922/ffd7f907/attachment.py>
More information about the PyQt
mailing list