forked from carla-simulator/rllib-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkill_failed_processes.py
30 lines (26 loc) · 965 Bytes
/
kill_failed_processes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
import signal
import time
from Helper import read_txt_file
previous_killed_time = '-1'
while True:
lines = read_txt_file('failed_pids')
killed = False
for l, line in enumerate(lines):
if previous_killed_time == -1:
break
if previous_killed_time in line:
pid_to_kill = lines[l+1].split('----')
pid_to_kill = pid_to_kill[1].replace(' ','').replace('\n','')
previous_killed_time = lines[l+1].split('----')[0]
print(f'Killed PID {pid_to_kill}')
os.kill(int(pid_to_kill), signal.SIGKILL)
killed = True
break
if not killed and len(lines) != 0:
pid_to_kill = lines[0].split('----')
pid_to_kill = pid_to_kill[1].replace(' ', '').replace('\n','')
previous_killed_time = lines[0].split('----')[0]
print(f'Killed PID {pid_to_kill}')
os.kill(int(pid_to_kill), signal.SIGKILL)
time.sleep(60)