Created
April 17, 2024 06:02
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
psutil==5.9.8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# `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