Replymessage unavailable
I don't know why you need to quit or terminate the thread from within but could it also be that you just delete it from outside?
import time
from PySide2 import QtCore, QtWidgets
class AThread(QtCore.QThread):
def __init__(self):
super(AThread, self).__init__()
self._run = True
self._count = 0
def _sleep(self):
time.sleep(0.5)
self._count += 1
if self._count > 5:
self._run = False
def run(self):
while True:
if self._run:
print("thread ping")
self._sleep()
else:
print("okithxbyeee")
break
if __name__ == "__main__":
app = QtWidgets.QApplication()
thr = AThread()
thr.finished.connect(thr.deleteLater)
thr.start()
app.exec_()