Then use subprocess:
(I have not tested the code)
Your problems goes deeper as you think. The whole structure is wrong.
I think a Queue can solve this problems.
Writing to a file and reading it from another process is very fragile.
(I have not tested the code)
import sys import time from subprocess import Popen def start_script(filename): proc = Popen([sys.executeable, filename]) return proc # s3nd and r3ceive are bad names sender_proc = start_script('s3nd.py') receiver_proc = start_script('r3ceive.py') # don't forget to put the if __name__ == '__main__' # into your modules bottom and call the sender and receiver. time.sleep(10) sender_proc.terminate() receiver_proc.terminate()The question is, what happens if receiver runs before sender?
Your problems goes deeper as you think. The whole structure is wrong.
I think a Queue can solve this problems.
Writing to a file and reading it from another process is very fragile.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!