Skip to content

Instantly share code, notes, and snippets.

@SFM61319
Created April 17, 2024 06:02
Show Gist options
  • Save SFM61319/dc6ce2ef117ccc831f6a6b6b6b25c797 to your computer and use it in GitHub Desktop.
Save SFM61319/dc6ce2ef117ccc831f6a6b6b6b25c797 to your computer and use it in GitHub Desktop.
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"]}%`).')
process.kill()
time.sleep(check_interval)
if __name__ == '__main__':
PROCESS_NAME = 'SteelSeriesEngine.exe'
THRESHOLD_CPU_PERCENTAGE = 10.0
CHECK_INTERVAL = 10.0
kill(PROCESS_NAME, THRESHOLD_CPU_PERCENTAGE, CHECK_INTERVAL)
# `Win` + `R` > `shell:startup` > `startup.bat` (say)
cmd /c start /min "" pythonw D:\Path\To\auto_kill_steel_series_gg_core.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment