33import subprocess
44import sys
55from threading import Thread
6+ from typing import Union
67
78from je_auto_control .utils .logging .loggin_instance import autocontrol_logger
89
@@ -21,7 +22,7 @@ def __init__(
2122 self .read_program_error_output_from_thread = None
2223 self .read_program_output_from_thread = None
2324 self .still_run_shell : bool = True
24- self .process = None
25+ self .process : Union [ subprocess . Popen , None ] = None
2526 self .run_output_queue : queue = queue .Queue ()
2627 self .run_error_queue : queue = queue .Queue ()
2728 self .program_encoding : str = shell_encoding
@@ -115,16 +116,16 @@ def print_and_clear_queue(self) -> None:
115116
116117 def read_program_output_from_process (self ) -> None :
117118 while self .still_run_shell :
118- program_output_data = self .process .stdout .raw . read (
119+ program_output_data = self .process .stdout .readline (
119120 self .program_buffer ) \
120- .decode (self .program_encoding )
121+ .decode (self .program_encoding , "replace" )
121122 self .run_output_queue .put_nowait (program_output_data )
122123
123124 def read_program_error_output_from_process (self ) -> None :
124125 while self .still_run_shell :
125- program_error_output_data = self .process .stderr .raw . read (
126+ program_error_output_data = self .process .stderr .readline (
126127 self .program_buffer ) \
127- .decode (self .program_encoding )
128+ .decode (self .program_encoding , "replace" )
128129 self .run_error_queue .put_nowait (program_error_output_data )
129130
130131
0 commit comments