python - 守护线程自动停止?
问题描述
这是一个场景:
档案一:
from fileb import StatusClass
class MainClass (tk.Tk):
#init
...
self.anotherclass = StatusClass(parent, controller)
#DOSOMESTUFF
self._startprgram()
文件 B:
class StatusClass (tk.Frame):
#init
...
self.anotherclass = StatusProcess
class StatusProcess (threading.Thread):
#init method
self.setDaemon(True)
def run():
while True:
#do stuff
发生的情况是,根据文件 A 中#DOSOMESTUFF 中的运行时间,创建的线程会停止。
如果我有一些指令,它会保留,但如果我什至添加 time.sleep 几秒钟,线程也会停止。有什么建议吗?
解决方案
推荐阅读
- postgresql - docker-compose up -d build 后恢复 Postgres db.dump 文件
- interface - USB真机接口在android studio 3.1中不显示
- c# - 如何将多个图像上传到数据库中以获得相同的 ID 并显示到 gridview 中?
- javascript - 为什么在线缩小器会更改我的代码?
- android - Android studio 3.1.4 工具栏卡在角落里
- html - 为什么我的新 div 会影响它之前的 div?
- mysql - 每次将新数据添加到数据库时如何从 1 增加 Id 列
- azure - 如何在 Azure 数据工厂的 Lookup 活动中只读取几行数据
- asynchronous - 如何为异步 WinHttpWebSocketSend 调用设置上下文?
- cordova - 离子代码推送更新失败:无法在 preInstallFailure 获取包起始页