Skip to content

Commit 344e0d8

Browse files
committed
Attempt to terminate subprocess before exiting
在打包子进程未结束时关闭主窗口,则会在退出前先尝试终止子进程;
1 parent 30707d7 commit 344e0d8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/py2exe_gui/__main__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ def run_packaging():
3535

3636
self.status_bar.showMessage("就绪")
3737

38+
def closeEvent(self, event):
39+
"""
40+
重写关闭事件,进行收尾清理 \n
41+
"""
42+
43+
if self.packager.subprocess.process:
44+
self.packager.subprocess.process.terminate() # 终止尚未结束的子进程
45+
self.packager.subprocess.process.waitForFinished()
46+
super(MainApp, self).closeEvent(event)
47+
3848

3949
app = QApplication(sys.argv)
4050
window = MainApp()

0 commit comments

Comments
 (0)