Created
July 21, 2022 01:04
-
-
Save bison--/b06e19bf71067733da2462f2a464c873 to your computer and use it in GitHub Desktop.
a simple and dirty CPU time burner
This file contains 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 subprocess | |
import time | |
thread_amount = int(input('amount of threads:')) | |
all_processes = [] | |
try: | |
for i in range(thread_amount): | |
all_processes.append(subprocess.Popen(["md5sum", "/dev/zero"])) | |
except Exception as ex: | |
print("Error: unable to start process", ex) | |
keep_running = True | |
try: | |
while keep_running: | |
time.sleep(1) | |
except KeyboardInterrupt: | |
keep_running = False | |
print('STOPPING') | |
for process in all_processes: | |
process.kill() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment