waveform_editor.shape_editor.nice_integration.OutputCommunicatorProtocol

class waveform_editor.shape_editor.nice_integration.OutputCommunicatorProtocol(on_output: Callable[[str | bytes], None])

Bases: SubprocessProtocol

Routes subprocess stdout/stderr to an output callback.

__init__(on_output: Callable[[str | bytes], None])

Methods

__init__(on_output)

connection_lost(exc)

Called when the connection is lost or closed.

connection_made(transport)

Called when a connection is made.

pause_writing()

Called when the transport's buffer goes over the high-water mark.

pipe_connection_lost(fd, exc)

Called when a file descriptor associated with the child process is closed.

pipe_data_received(fd, data)

Called when the subprocess writes data into stdout/stderr pipe.

process_exited()

Called when subprocess has exited.

resume_writing()

Called when the transport's buffer drains below the low-water mark.

connection_lost(exc)

Called when the connection is lost or closed.

The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed).

connection_made(transport)

Called when a connection is made.

The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.

pause_writing()

Called when the transport's buffer goes over the high-water mark.

Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark.

Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero.

NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called).

pipe_connection_lost(fd, exc)

Called when a file descriptor associated with the child process is closed.

fd is the int file descriptor that was closed.

pipe_data_received(fd, data)

Called when the subprocess writes data into stdout/stderr pipe.

fd is int file descriptor. data is bytes object.

process_exited()

Called when subprocess has exited.

resume_writing()

Called when the transport's buffer drains below the low-water mark.

See pause_writing() for details.


Last update: 2026-05-21