-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (31 loc) · 1.13 KB
/
Copy pathmain.py
File metadata and controls
36 lines (31 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import multiprocessing
from mess_web import mess_host
from characterai_web import cai_host
import time
if __name__ == '__main__':
try:
users_queue = multiprocessing.Queue()
bot_queue = multiprocessing.Queue()
messenger_proc = multiprocessing.Process(target=mess_host.main, args=(users_queue, bot_queue))
messenger_proc.start()
cai_proc = multiprocessing.Process(target=cai_host.main, args=(users_queue, bot_queue))
cai_proc.start()
# Monitoring loop
while True:
if not messenger_proc.is_alive():
print("Messenger process exited. Terminating CAI process...")
cai_proc.terminate()
break
if not cai_proc.is_alive():
print("CAI process exited. Terminating Messenger process...")
messenger_proc.terminate()
break
time.sleep(1) # Check every second
except KeyboardInterrupt:
print("Exiting...")
messenger_proc.terminate()
cai_proc.terminate()
finally:
messenger_proc.join()
cai_proc.join()
print("Exited")