I have a function that calls another function. I need everything to terminate after 5 seconds. The second function takes hours if let run to completion. How can I stop everything from running after 5 seconds without making changes to the second function? To clarify,
import datetime
def script1(arg):
    end_time = datetime.datetime.now() + datetime.timedelta(seconds=5)
    while True:
        if datetime.datetime.now() >= end_time:
            break
        else:
            os.system("python3 script2.py")
Currently I get stuck on the last line for the entirety of scrip2. I need it to terminate after 5 seconds.
 
    