Pipe — Named pipe handle

class pyuv.Pipe(loop, ipc)
Parameters:
  • loop (Loop) – loop object where this handle runs (accessible through Pipe.loop).
  • ipc (boolean) – Indicate if this Pipe will be used for IPC connection.

The Pipe handle provides asynchronous named pipe functionality both as a client and server, supporting cross-process communication and handle sharing.

bind(name)
Parameters:name (string) – Name of the pipe to bind to.

Bind to the specified pipe name. The Pipe handle is acting as a server in this case.

listen(callback[, backlog])
Parameters:
  • callback (callable) – Callback to be called on every new connection. accept() should be called in that callback in order to accept the incoming connection.
  • backlog (int) – Indicates the length of the queue of incoming connections. It defaults to 128.

Start listening for new connections.

Callback signature: callback(pipe_handle, error).

open(fd)
Parameters:fd (int) – File descriptor to be opened.

Open the given file descriptor (or HANDLE in Windows) as a Pipe.

accept(client)
Parameters:client (object) – Client object where to accept the connection.

Accept a new incoming connection which was pending. This function needs to be called in the callback given to the listen() function or in the callback given to the start_read2() is there is any pending handle.

connect(name, callback)
Parameters:
  • name (string) – Name of the pipe to connect to.
  • callback (callable) – Callback to be called when the connection to the remote endpoint has been made.

Initiate a client connection to the specified named pipe.

Callback signature: callback(pipe_handle, error).

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

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

Callback signature: callback(pipe_handle, error).

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

Write data on the Pipe connection.

Callback signature: callback(tcp_handle, error).

writelines(seq[, callback])
Parameters:
  • seq (object) – Data to be written on the Pipe connection. It can be any iterable object and the same logic is applied for the contained elements as in the write method.
  • callback (callable) – Callback to be called after the write operation has been performed.

Write data on the Pipe connection.

Callback signature: callback(tcp_handle, error).

write2(data, handle[, callback])
Parameters:
  • data (object) – Data to be written on the Pipe connection. It can be either a string or any iterable containing strings.
  • handle (object) – Handle to send over the Pipe. Currently only TCP, UDP and Pipe handles are supported.
  • callback (callable) – Callback to be called after the write operation has been performed.

Write data on the Pipe connection.

Callback signature: callback(pipe_handle, error).

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

Start reading for incoming data from the remote endpoint.

Callback signature: callback(pipe_handle, data, error).

start_read2(callback)
Parameters:callback (callable) – Callback to be called when data is read from the remote endpoint.

Start reading for incoming data or a handle from the remote endpoint.

Callback signature: callback(pipe_handle, data, pending, error).

stop_read()

Stop reading data from the remote endpoint.

pending_instances(count)
Parameters:count (int) – Number of pending instances.

This setting applies to Windows only. Set the number of pending pipe instance handles when the pipe server is waiting for connections.

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.

Previous topic

UDP — UDP handle

Next topic

TTY — TTY controlling handle

This Page