创建多个线程使用计时器时如何管理Qthreads?

时间:2019-03-31 13:02:11

标签: python pyqt5

我想用Qtimer创建一些Qthread,但是几秒钟后,程序将突然退出,所以我想知道如何管理那些线程以更合理地利用线程?

使用PyQt5,QThread,

self.time_flash.timeout.connect(self.start_face)

def open_face(self):
     # when I make time bigger
     # The program will run more long time before auto exit.
     time = 3000
    self.time_flash.start(time)    

def start_face(self):
          self.thread = ResThread()
          self.thread.start()

我想知道有关自动退出的原因。也许是内存不足了?而且我想知道如何解决它。 (谢谢)

1 个答案:

答案 0 :(得分:0)

.thread属性是Qobject api的一部分,您正在覆盖它。只需将self.thread替换为其他内容,就可以了

这是文档https://doc.qt.io/Qt-5/qobject.html#thread

相关问题