I have a QThread that emits finished() signal, but its isFinished() returns False. Why is that? How to know when isFinished will start to return True?
from __future__ import print_function
from PySide import QtCore, QtGui
qapp = QtGui.QApplication([])
worker_thread = QtCore.QThread()
worker_thread.start()
worker_thread.quit()
def fin():
print('isFinished:', worker_thread.isFinished())
worker_thread.finished.connect(fin)
QtCore.QTimer.singleShot(200, qapp.quit)
qapp.exec_()
sometimes it returns true, but most of the time it outputs:
isFinished: False
answer in another SO question(QThread emits finished() signal but isRunning() returns true and isFinished() returns false) suggests that it should be like this:
- At this point, isFinished() should start returning true and isRunning() false.
- The internals emit the finished() signal.
- py 2.7.4
- PySide 1.1.2
- Qt 4.8.2
also tested with PyQt4