aboutsummaryrefslogtreecommitdiffstats
path: root/runprog.py
blob: 4568c59417a9cf69e33a943460667dc48ef816db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from time import sleep
import subprocess
import multiprocessing

def thread_():
    subprocess.run(["python3", "SmallYTChannelBotSubmissions.py"])

while True:
    thread = multiprocessing.Process(target = thread_, args = ())
    thread.start()

    sleep(60 * 60 * 2)

    print("closing...")
    file = open("pid.txt", "r")
    pid = file.readlines()[0]
    file.close()

    subprocess.run(["kill", pid])
    thread.terminate()

    print("killed ", pid)