-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (25 loc) · 884 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from os import environ, execl, path
from sys import executable
from time import sleep
from psutil import virtual_memory
def ram_to_consume():
memory_to_allocate = virtual_memory().total * float(f"0.{int(TAKE) if (TAKE := environ.get("TAKE")) else 15}") - virtual_memory().used
if memory_to_allocate > 0:
allocated_mem = bytearray(int(memory_to_allocate))
print(f"Allocated {len(allocated_mem)} bytes to reach target memory usage.")
return allocated_mem
else:
print("No need to allocate memory.")
return None
allocated_mem = ram_to_consume()
print("Done!")
while not sleep(24 * 3600):
if not environ.get("NOCPUB"):
result = 1
for i in range(1, 1000000):
result *= i
args = [
executable,
"main.py" if path.isfile("main.py") else "main.pyc",
]
execl(executable, *args)