Из-за чего появляется такой вывод? Вроде обрабатываю исключение на остановку программы, а ошибка вообще в другом моменте вылезает
from src.node.node import Node
from multiprocessing import Process, Queue
import time
import sys
class OutputProcess(Process):
def __init__(self, output_queue) -> None:
super().__init__()
self.output_queue = output_queue
def run(self):
while True:
time.sleep(1)
if not self.output_queue.empty():
print(self.output_queue.get())
class ConsoleUser:
def __init__(self) -> None:
self.node = Node()
self.username = 'ccoin_client'
self.__processes = []
self.res_values = Queue()
self.__start_output()
def start_input(self):
while True:
try:
command = input(f'{self.username}: ')
self.res_values.put(command)
except Exception as e:
for process in self.__processes:
process.terminate()
print(str(e))
sys.exit(0)
def __append_process(func):
def wrapper(*args, **kwargs):
args[0].__processes.append(func(*args, **kwargs))
return wrapper
@__append_process
def __start_output(self):
self.output_process = OutputProcess(self.res_values)
self.output_process.start()
return self.output_process
Вывод:
ccoin_client: ^CTraceback (most recent call last):
File "/home/eugene/Documents/NIR_refactoring/main.py", line 8, in <module>
user.start_input()
File "/home/eugene/Documents/NIR_refactoring/src/console_user/console_user.py", line 34, in start_input
command = input(f'{self.username}: ')
KeyboardInterrupt
Process OutputProcess-1:
Traceback (most recent call last):
File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/home/eugene/Documents/NIR_refactoring/src/console_user/console_user.py", line 13, in run
time.sleep(1)
KeyboardInterrupt