(self, queues, codepage, input_streams, output_streams)
Initialise I/O streams.
Initialise I/O streams.
Initialise I / O streams .
def __init__(self, queues, codepage, input_streams, output_streams):
        """Initialise I/O streams."""
        self._queues = queues
        self._codepage = codepage
        # input
        if input_streams in (u'stdio', b'stdio'):
            # sentinel value
            # stdin needs to be picked at runtime as both console.stdin and sys.stdin can change
            # and we would be keeping a reference to a closed/bad file
            input_streams = stdio.stdin
        # put in tuple if it's file-like so we do the right thing when looping
        if not input_streams:
            input_streams = ()
        elif hasattr(input_streams, 'read') or not isinstance(input_streams, Iterable):
            input_streams = (input_streams,)
        self._input_streams = [self._wrap_input(stream) for stream in input_streams]
        # output
        if output_streams in (u'stdio', b'stdio'):
            output_streams = stdio.stdout
        # put in tuple if it's file-like so we do the right thing when looping
        if not output_streams:
            output_streams = ()
        elif hasattr(output_streams, 'write') or not isinstance(output_streams, Iterable):
            output_streams = (output_streams,)
        self._output_echos = [
            self._codepage.wrap_output_stream(stream, preserve=CONTROL)
            for stream in output_streams
        ]
        # disable at start
        self._active = False
        # launch a daemon thread for input
        self._stop_threads = False
        if self._input_streams:
            # launch a thread to allow nonblocking reads on both Windows and Unix
            thread = threading.Thread(target=self._process_input, args=())
            thread.daemon = True
            thread.start()
def __init__ ( self , queues , codepage , input_streams , output_streams ) : self . _queues = queues self . _codepage = codepage # input if input_streams in ( u'stdio' , b'stdio' ) : # sentinel value # stdin needs to be picked at runtime as both console.stdin and sys.stdin can change # and we would be keeping a reference to a closed/bad file input_streams = stdio . stdin # put in tuple if it's file-like so we do the right thing when looping if not input_streams : input_streams = ( ) elif hasattr ( input_streams , 'read' ) or not isinstance ( input_streams , Iterable ) : input_streams = ( input_streams , ) self . _input_streams = [ self . _wrap_input ( stream ) for stream in input_streams ] # output if output_streams in ( u'stdio' , b'stdio' ) : output_streams = stdio . stdout # put in tuple if it's file-like so we do the right thing when looping if not output_streams : output_streams = ( ) elif hasattr ( output_streams , 'write' ) or not isinstance ( output_streams , Iterable ) : output_streams = ( output_streams , ) self . _output_echos = [ self . _codepage . wrap_output_stream ( stream , preserve = CONTROL ) for stream in output_streams ] # disable at start self . _active = False # launch a daemon thread for input self . _stop_threads = False if self . _input_streams : # launch a thread to allow nonblocking reads on both Windows and Unix thread = threading . Thread ( target = self . _process_input , args = ( ) ) thread . daemon = True thread . start ( )