Maybe this will suffice
File1.py:
File1.py:
import File2 while True: a = input() if a == "start": File2.run_func = True threading.Thread(target = File2.func).start() if a == "stop": #stop function File2.func File2.run_func = FalseFile2.py:
run_func = True def func(): while run_func: #do stuffEdit: I removed the
()
from File2.func as the thread should call the function