Closed kalvdans closed 8 months ago
Hi,
According to the docs:
The object reference returned by this function is valid until the QCoreApplication's destructor is run, when the connection will be closed and the object, deleted.
So it seems the behavior is as expected: the connection/thread will stay open until P QCoreApplication` is destroyed, which will only happen at the end of the session. I don't think this is a bug in QT either, just the expected behavior.
Closing this for now, feel free to follow up with other questions.
Thanks @nicoddemus ! I thought the qapp fixture did a proper teardown but I see now in the source code that it keeps the QApplication object alive forever in a global variable.
Do you have any advice how to make our tests more isolated? Will you accept a pull request making QApplication live shorter or is that playing with fire?
I thought the qapp fixture did a proper teardown but I see now in the source code that it keeps the QApplication object alive forever in a global variable.
Yes, this is due to a limitation within Qt itself, you cannot destroy and recreate QApplication within the same process more than once.
Do you have any advice how to make our tests more isolated?
In general it is good for tests to cleanup after themselves, (for example using a fixture which stops a thread started during the test), but I'm not sure this can be done with systemBus()
, as it explicitly states the thread will only be closed when QApplication is destroyed...
Will you accept a pull request making QApplication live shorter or is that playing with fire?
As I mentioned this is not really possible, I'm afraid.
We have an unit test that connects to dbus with QDBusConnection.systemBus(), and it seems to create a thread that exist even after the unit test has been torn down. This disturbs other completely unrelated tests later on.
Small reproducer:
Running gives output:
Please tell me if you think this should be reported to QT instead.