Create funnee_multi.py

This commit is contained in:
Carlos Sanchez 2024-02-06 18:48:21 -05:00
parent 09b12693b8
commit 5adec0cbab
1 changed files with 40 additions and 0 deletions

40
client/funnee_multi.py Normal file
View File

@ -0,0 +1,40 @@
import subprocess
import time
import multiprocessing
def run_process(command):
while True:
try:
print(f"Running: {command}")
subprocess.run(command, shell=True, check=True)
except subprocess.CalledProcessError as e:
print(f"Process stopped with error: {e}")
time.sleep(10)
def main():
processes = []
# Add your command for each process
commands = [
"python broadcast.py broadcast_haloopdy.toml",
"python broadcast.py broadcast_haloopdy_webcam.toml",
"python watch.py watch_fier.toml"
]
# Start processes
for cmd in commands:
process = multiprocessing.Process(target=run_process, args=(cmd,))
processes.append(process)
process.start()
try:
# Monitor for key press to stop all processes
input("Press Enter to stop all processes...")
finally:
# Terminate all processes when the key is pressed
for process in processes:
process.terminate()
process.join()
if __name__ == "__main__":
main()