TTY — TTY controlling handle

class pyuv.TTY(loop, fd, readable)
Parameters:
  • loop (Loop) – loop object where this handle runs (accessible through TTY.loop).
  • fd (int) – File descriptor to be opened as a TTY.
  • readable (bool) – Specifies if the given fd is readable.

The TTY handle provides asynchronous stdin / stdout functionality.

shutdown([callback])
Parameters:callback (callable) – Callback to be called after shutdown has been performed.

Shutdown the outgoing (write) direction of the TTY connection.

Callback signature: callback(tty_handle).

write(data[, callback])
Parameters:
  • data (object) – Data to be written on the TTY connection. It can be any Python object conforming to the buffer interface or a sequence of such objects.
  • callback (callable) – Callback to be called after the write operation has been performed.

Write data on the TTY connection.

Callback signature: callback(tcp_handle, error).

try_write(data)
Parameters:data (object) – Data to be written on the TTY connection. It can be any Python object conforming to the buffer interface.

Try to write data on the TTY connection. It will raise an exception if data cannot be written immediately or a number indicating the amount of data written.

start_read(callback)
Parameters:callback (callable) – Callback to be called when data is read.

Start reading for incoming data.

Callback signature: callback(status_handle, data).

stop_read()

Stop reading data.

set_mode(mode)
Parameters:mode (int) – TTY mode. 0 for normal, 1 for raw.

Set TTY mode.

get_winsize()

Get terminal window size.

fileno()

Return the internal file descriptor (or HANDLE in Windows) used by the TTY handle.

Warning

libuv expects you not to modify the file descriptor in any way, and if you do, things will very likely break.

classmethod reset_mode()

Reset TTY settings. To be called when program exits.

write_queue_size

Read only

Returns the size of the write queue.

readable

Read only

Indicates if this handle is readable.

writable

Read only

Indicates if this handle is writable.