-
-
Save ishan1608/87cb762f31b7af70a867 to your computer and use it in GitHub Desktop.
"""Heater | |
A program that spawns as much number of processes as there are CPUs on the computer. | |
This keeps the core temprature high. | |
I made this so that my fingers feel more comfortable while working on my laptop during winter. | |
Caution : An eye should be kept on the CPU temprature so that when it is getting too hot, | |
the prgoram needs to be killed; else it can damage the CPU. | |
Author : Ishan | |
Email : [email protected] | |
""" | |
import multiprocessing | |
import sys | |
def round_robin_count(): | |
while(True): | |
number = 0 | |
if(number >= sys.maxsize): | |
number = 0 | |
else: | |
number = number + 1 | |
if __name__ == "__main__": | |
if len(sys.argv) == 2 and sys.argv[1] == '--about': | |
print(__doc__) | |
elif len(sys.argv) == 2 and sys.argv[1] == '--help': | |
print('Heater', 'USAGE: python3 ' + sys.argv[0] + ' [option]', sep='\n') | |
print('To read about.', 'python3 ' + sys.argv[0] + ' --about' ,sep=' ') | |
print('To see this help message.', 'python3 ' + sys.argv[0] + ' --help', sep=' ') | |
else: | |
process_count = 1 | |
print('Heating up the CPU') | |
while(process_count <= multiprocessing.cpu_count()): | |
process_to_be_not_seen_again = multiprocessing.Process(target=round_robin_count) | |
process_to_be_not_seen_again.start() | |
process_count += 1 | |
@hacker1024 I never owned a macbook, so couldn't test it on mac os.
If you find a solution let me know, I'll update the gist. And if I find a solution that works. I'll update the gist here.
Update: As it turns out just wrapping the main code in if __name__ == '__main__':
solves the problem.
For more context you can look at this comment https://stackoverflow.com/questions/61931669/python-multiprocessing-runtimeerror-an-attempt-has-been-made-to-start-a-new-pro#comment109560442_61931669
How do you use it or like turn it on or control it or whatever
@TreWade1469 I execute the python script and when I feel my fingers are warm enough, I kill the process using ctrl + c
.
How do you download it, and turn it on?
@TreWade1469 Running a python script is a pretty basic step. (Not that I am assuming anything here).
But, if you don't know how to do that. May I please ask you not to run this script and rather first learn the basics of python first.
There are tons of tutorials/courses available on the internet.
Please go through them first as running this script could be dangerous and kill your device.
I don't want you to mistakenly harm your device.
Ok thanks
@ishan1608
Instead of
process_to_be_not_seen_again = multiprocessing.Process(target=round_robin_count)
process_to_be_not_seen_again.start()
Use:
if __name__ == "__main__":
process_to_be_not_seen_again = multiprocessing.Process(target=round_robin_count)
process_to_be_not_seen_again.start()
@Speed3k-python That piece of code is already inside the if __name__ == "__main__":
block.
What would adding another redundant condition do?
This is for the ants in my laptop!
This is for the ants in my laptop!
🤣 Never thought of this use case.
man ur a life saver I was wearing shorts and using my MacBook so it hit me with an extreme cold so I am now using this much love!
HOW TO STOP IT HELP!!!!
Doesn't run on macOS 11.3.1 with Python 3.9.1: