Subprocess File Readers (xonsh.procs.readers
)¶
File handle readers and related tools.
-
class
xonsh.procs.readers.
BufferedFDParallelReader
(fd, buffer=None, chunksize=1024)[source]¶ Buffered, parallel background thread reader.
- Parameters
- fdint
File descriptor from which to read.
- bufferbinary file-like or None, optional
A buffer to write bytes into. If None, a new BytesIO object is created.
- chunksizeint, optional
The max size of the parallel reads, default 1 kb.
-
class
xonsh.procs.readers.
ConsoleParallelReader
(fd, buffer=None, chunksize=1024, timeout=None)[source]¶ Parallel reader for consoles that runs in a background thread. This is only needed, available, and useful on Windows.
- Parameters
- fdint
Standard buffer file descriptor, 0 for stdin, 1 for stdout (default), and 2 for stderr.
- bufferctypes.c_wchar_p, optional
An existing buffer to (re-)use.
- chunksizeint, optional
The max size of the parallel reads, default 1 kb.
- timeoutfloat, optional
The queue reading timeout.
-
class
xonsh.procs.readers.
NonBlockingFDReader
(fd, timeout=None)[source]¶ A class for reading characters from a file descriptor on a background thread. This has the advantages that the calling thread can close the file and that the reading does not block the calling thread.
- Parameters
- fdint
A file descriptor
- timeoutfloat or None, optional
The queue reading timeout.
-
class
xonsh.procs.readers.
QueueReader
(fd, timeout=None)[source]¶ Provides a file-like interface to reading from a queue.
- Parameters
- fdint
A file descriptor
- timeoutfloat or None, optional
The queue reading timeout.
-
xonsh.procs.readers.
populate_buffer
(reader, fd, buffer, chunksize)[source]¶ Reads bytes from the file descriptor and copies them into a buffer.
The reads happen in parallel using the pread() syscall; which is only available on POSIX systems. If the read fails for any reason, the reader is flagged as closed.
-
xonsh.procs.readers.
populate_console
(reader, fd, buffer, chunksize, queue, expandsize=None)[source]¶ Reads bytes from the file descriptor and puts lines into the queue. The reads happened in parallel, using xonsh.winutils.read_console_output_character(), and is thus only available on windows. If the read fails for any reason, the reader is flagged as closed.