Skip to content

Instantly share code, notes, and snippets.

View SFM61319's full-sized avatar
🏠
Working from home

Avinash Maddikonda SFM61319

🏠
Working from home
View GitHub Profile
@SFM61319
SFM61319 / auto_kill_steel_series_gg_core.py
Created April 17, 2024 06:02
Auto-kills Steel Series GG Core if it starts leaking resources (i.e., uses >10% CPU). Polls every 10 seconds by default (can be changed).
import time
import psutil
def kill(process_name: str, threshold_cpu_percentage: float, check_interval: float) -> None:
while True:
for process in psutil.process_iter(['pid', 'name', 'cpu_percent']):
if process.info['name'] == process_name and process.info['cpu_percent'] > threshold_cpu_percentage:
print(f'Killing `{process_name}` (PID `{process.info["pid"]}`) due to high CPU usage percentage (`{process.info["cpu_percent"]}%`).')