-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
由于weather插件是开启线程循环的,如果没有添加线程守护,即使通过Ctrl C也无法完全中断程序,会造成主程序中断但是卡在weather线程上,影响开发调试工作。而且当用户已经决定要中断主程序了,weather插件也没有后台继续完成任务的必要性。如图:
因此建议改为守护线程模式:
...
@register
class Weather(Plugin):
name = "weather"
def __init__(self, config: dict):
super().__init__(config)
scheduler_thread = threading.Thread(target=self.start_schedule)
scheduler_thread.daemon = True #这里设置线程为守护模式,主程序退出时线程随即被终止
scheduler_thread.start()
...Metadata
Metadata
Assignees
Labels
No labels
