A (de)serializer that wraps a certain serialization protocol. Currently it only supports the standard pickle protocol. It can optionally compress the serialized data, and is thread safe.
Deserializes the given data (bytes). Set compressed to True to decompress the data first.
Serialize the given data object, try to compress if told so. Returns a tuple of the serialized data (bytes) and a bool indicating if it is compressed or not.
An exception hook you can use for sys.excepthook, to automatically print remote Pyro tracebacks
function to hack around a bug in IronPython where it doesn’t pickle exception attributes. We piggyback them into the exception’s args.
Formats an exception traceback. If you ask for detailed formatting, the result will contain info on the variables in each stack frame. You don’t have to provide the exception info objects, if you omit them, this function will obtain them itself using sys.exc_info().
Returns a list of strings that form the traceback information of a Pyro exception. Any remote Pyro exception information is included. Traceback information is automatically obtained via sys.exc_info() if you do not supply the objects yourself.
Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a ‘_‘. If the optional allowDotted argument is false, dots are not supported and this function operates similar to getattr(obj, attr).
Low level socket utilities.
A wrapper class for plain sockets, containing various methods such as send() and recv()
Bind the socket to a free port and return the port number. This code is based on the code in the stdlib’s test.test_support module.
Create a udp broadcast socket. Set ipv6=True to create an IPv6 socket rather than IPv4. Set ipv6=None to use the PREFER_IP_VERSION config setting.
Create a socket. Default socket options are keepalive and IPv4 family. If ‘bind’ or ‘connect’ is a string, it is assumed a Unix domain socket is requested. Otherwise, a normal tcp/ip socket is used. Set ipv6=True to create an IPv6 socket rather than IPv4. Set ipv6=None to use the PREFER_IP_VERSION config setting.
Returns an unused port that should be suitable for binding (likely, but not guaranteed). This code is copied from the stdlib’s test.test_support module.
tries to find the ip address of the interface that connects to a given host
Returns the IP address for the given host. If you enable the workaround, it will use a little hack if the ip address is found to be the loopback address. The hack tries to discover an externally visible ip address instead (this only works for ipv4 addresses). Set ipVersion=6 to return ipv6 addresses, 4 to return ipv4, 0 to let OS choose the best one or None to use Pyro4.config.PREFER_IP_VERSION.
Determine what the IP version is of the given hostname or ip address (4 or 6). First, it resolves the hostname or address to get an IP address. Then, if the resolved IP contains a ‘:’ it is considered to be an ipv6 address, and if it contains a ‘.’, it is ipv4.
Retrieve a given number of bytes from a socket. It is expected the socket is able to supply that number of bytes. If it isn’t, an exception is raised (you will not get a zero length result or a result that is smaller than what you asked for). The partial data that has been received however is stored in the ‘partialData’ attribute of the exception object.
Send some data over a socket. Some systems have problems with sendall() when the socket is in non-blocking mode. For instance, Mac OS X seems to be happy to throw EAGAIN errors too often. This function falls back to using a regular send loop if needed.
sets the SO_KEEPALIVE option on the socket, if possible.
Mark the given socket fd as non-inheritable to child processes
sets the SO_REUSEADDR option on the socket, if possible.
Threading abstraction which allows for threading2 use with a transparent fallback to threading when it is not available. Pyro doesn’t use threading directly: it imports all thread related items via this module instead. Code using Pyro can do the same (but it is not required).