Skip to content

Commit 5432968

Browse files
committed
修复定时重启与异常退出时进程锁可能未释放的bug
1 parent 9035667 commit 5432968

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,20 @@ def main():
3838
print(f'进程{p.name}异常退出, exitcode={p.process.exitcode}')
3939
p.process.terminate()
4040
p.process = None
41+
# 解除进程锁
42+
try:
43+
proc_lock.release()
44+
except ValueError:
45+
pass
4146
elif p.start_time + 60 * 60 < time.time(): # 最长运行1小时就重启
4247
print(f'进程{p.name}运行太久,重启')
4348
p.process.terminate()
4449
p.process = None
50+
# 解除进程锁
51+
try:
52+
proc_lock.release()
53+
except ValueError:
54+
pass
4555

4656
time.sleep(0.2)
4757

0 commit comments

Comments
 (0)