modal.io_streams
modal.io_streams.StreamReader
Retrieve logs from a stream (stdout or stderr).
As an asynchronous iterable, the object supports the for and async for statements. Just loop over the object to read in chunks.
file_descriptor
Possible values are 1 for stdout and 2 for stderr.
read
Fetch the entire contents of the stream until EOF.
modal.io_streams.StreamWriter
Provides an interface to buffer and write logs to a sandbox or container process stream (stdin).
write
Write data to the stream but does not send it immediately.
This is non-blocking and queues the data to an internal buffer. Must be
used along with the drain() method, which flushes the buffer.
Usage
write_eof
Close the write end of the stream after the buffered data is drained.
If the process was blocked on input, it will become unblocked after write_eof(). This method needs to be used along with the drain() method, which flushes the EOF to the process.
drain
Flush the write buffer and send data to the running process.
This is a flow control method that blocks until data is sent. It returns when it is appropriate to continue writing data to the stream.
Usage
Async usage: