Streams
An abstraction layer over OS-dependent file-like objects, that provides a consistent view of a duplex byte stream.
- class rpyc.core.stream.Stream[source]
Base Stream
- property closed
tests whether the stream is closed or not
- class rpyc.core.stream.SocketStream(sock)[source]
A stream over a socket
- classmethod connect(host, port, **kwargs)[source]
factory method that creates a
SocketStream
over a socket connected to host and port- Parameters:
host – the host name
port – the TCP port
family – specify a custom socket family
socktype – specify a custom socket type
proto – specify a custom socket protocol
timeout – connection timeout (default is 3 seconds)
nodelay – set the TCP_NODELAY socket option
keepalive – enable TCP keepalives. The value should be a boolean, but on Linux, it can also be an integer specifying the keepalive interval (in seconds)
ipv6 – if True, creates an IPv6 socket (
AF_INET6
); otherwise an IPv4 (AF_INET
) socket is created
- Returns:
- classmethod unix_connect(path, timeout=3)[source]
factory method that creates a
SocketStream
over a unix domain socket located in path- Parameters:
path – the path to the unix domain socket
timeout – socket timeout
- classmethod ssl_connect(host, port, ssl_kwargs, **kwargs)[source]
factory method that creates a
SocketStream
over an SSL-wrapped socket, connected to host and port with the given credentials.- Parameters:
host – the host name
port – the TCP port
ssl_kwargs – a dictionary of keyword arguments for
ssl.SSLContext
andssl.SSLContext.wrap_socket
kwargs – additional keyword arguments:
family
,socktype
,proto
,timeout
,nodelay
, passed directly to thesocket
constructor, oripv6
.ipv6 – if True, creates an IPv6 socket (
AF_INET6
); otherwise an IPv4 (AF_INET
) socket is created
- Returns:
- property closed
tests whether the stream is closed or not
- class rpyc.core.stream.TunneledSocketStream(sock)[source]
A socket stream over an SSH tunnel (terminates the tunnel when the connection closes)
- class rpyc.core.stream.Win32PipeStream(incoming, outgoing)[source]
A stream over two simplex pipes (one used to input, another for output). This is an implementation for Windows pipes (which suck)
- property closed
tests whether the stream is closed or not
- read(count)[source]
reads exactly count bytes, or raise EOFError
- Parameters:
count – the number of bytes to read
- Returns:
read data
- class rpyc.core.stream.NamedPipeStream(handle, is_server_side)[source]
A stream over two named pipes (one used to input, another for output). Windows implementation.
- classmethod create_server(pipename, connect=True)[source]
factory method that creates a server-side
NamedPipeStream
, over a newly-created named pipe of the given name.- Parameters:
pipename – the name of the pipe. It will be considered absolute if it starts with
\\.
; otherwise\\.\pipe\rpyc
will be prepended.connect – whether to connect on creation or not
- Returns:
a
NamedPipeStream
instance
- connect_server()[source]
connects the server side of an unconnected named pipe (blocks until a connection arrives)
- classmethod create_client(pipename)[source]
factory method that creates a client-side
NamedPipeStream
, over a newly-created named pipe of the given name.- Parameters:
pipename – the name of the pipe. It will be considered absolute if it starts with
\\.
; otherwise\\.\pipe\rpyc
will be prepended.- Returns:
a
NamedPipeStream
instance
- read(count)[source]
reads exactly count bytes, or raise EOFError
- Parameters:
count – the number of bytes to read
- Returns:
read data
- class rpyc.core.stream.PipeStream(incoming, outgoing)[source]
A stream over two simplex pipes (one used to input, another for output)
- classmethod from_std()[source]
factory method that creates a PipeStream over the standard pipes (
stdin
andstdout
)- Returns:
a
PipeStream
instance
- classmethod create_pair()[source]
factory method that creates two pairs of anonymous pipes, and creates two PipeStreams over them. Useful for
fork()
.- Returns:
a tuple of two
PipeStream
instances
- property closed
tests whether the stream is closed or not
Channel
Channel is an abstraction layer over streams that works with packets of data, rather than an endless stream of bytes, and adds support for compression.
- class rpyc.core.channel.Channel(stream, compress=True)[source]
Channel implementation.
Note: In order to avoid problems with all sorts of line-buffered transports, we deliberately add
\n
at the end of each frame.- property closed
indicates whether the underlying stream has been closed