This commit is contained in:
2023-08-14 17:03:00 +08:00
parent 576470f70a
commit 96cf7dfe74
12 changed files with 58 additions and 25 deletions

View File

@@ -8,15 +8,12 @@ PIDFILE = '/tmp/uengine-runner.pid'
#程序结束时清理pid
@atexit.register
def remove_pid():
try:
with open(PIDFILE) as pidfile:
pidlst = pidfile.readlines()
pidlst.remove(str(PID)+'\n')
with open(PIDFILE,'w') as pidfile:
pidfile.writelines(pidlst)
except:
# 忽略
pass
'''程序结束时清理pid'''
with open(PIDFILE) as pidfile:
pidlst = pidfile.readlines()
pidlst.remove(str(PID)+'\n') #移除记录中的pid
with open(PIDFILE,'w') as pidfile:
pidfile.writelines(pidlst)
#更新时结束进程
def main():
@@ -25,7 +22,7 @@ def main():
os.kill(int(i),15)
except ProcessLookupError:
pass
os.remove(PIDFILE)
## os.remove(PIDFILE) #因修复#I6ZRZX而注释
#当该程序被直接执行时执行结束进程操作。如果是导入的形式则只是记录pid
if __name__ == '__main__':