Registry

RPyC registry server implementation. The registry is much like Avahi or Bonjour, but tailored to the needs of RPyC. Also, neither of them supports (or supported) Windows, and Bonjour has a restrictive license. Moreover, they are too “powerful” for what RPyC needed and required too complex a setup.

If anyone wants to implement the RPyC registry using Avahi, Bonjour, or any other zeroconf implementation – I’ll be happy to include them.

Refer to rpyc/scripts/rpyc_registry.py for more info.

class rpyc.utils.registry.RegistryServer(listenersock, pruning_timeout=None, logger=None)[source]

Base registry server

on_service_added(name, addrinfo)[source]

called when a new service joins the registry (but not on keepalives). override this to add custom logic

on_service_removed(name, addrinfo)[source]

called when a service unregisters or is pruned. override this to add custom logic

cmd_query(host, name)[source]

implementation of the query command

cmd_register(host, names, port)[source]

implementation of the register command

cmd_unregister(host, port)[source]

implementation of the unregister command

start()[source]

Starts the registry server (blocks)

close()[source]

Closes (terminates) the registry server

class rpyc.utils.registry.UDPRegistryServer(host='0.0.0.0', port=18811, pruning_timeout=None, logger=None)[source]

UDP-based registry server. The server listens to UDP broadcasts and answers them. Useful in local networks, were broadcasts are allowed

class rpyc.utils.registry.TCPRegistryServer(host='0.0.0.0', port=18811, pruning_timeout=None, logger=None, reuse_addr=True)[source]

TCP-based registry server. The server listens to a certain TCP port and answers requests. Useful when you need to cross routers in the network, since they block UDP broadcasts

class rpyc.utils.registry.RegistryClient(ip, port, timeout, logger=None)[source]

Base registry client. Also known as registrar

discover(name)[source]

Sends a query for the specified service name.

Parameters:name – the service name (or one of its aliases)
Returns:a list of (host, port) tuples
register(aliases, port)[source]

Registers the given service aliases with the given TCP port. This API is intended to be called only by an RPyC server.

Parameters:
  • aliases – the service's aliases
  • port – the listening TCP port of the server
unregister(port)[source]

Unregisters the given RPyC server. This API is intended to be called only by an RPyC server.

Parameters:port – the listening TCP port of the RPyC server to unregister
class rpyc.utils.registry.UDPRegistryClient(ip='255.255.255.255', port=18811, timeout=2, bcast=None, logger=None, ipv6=False)[source]

UDP-based registry clients. By default, it sends UDP broadcasts (requires special user privileges on certain OS’s) and collects the replies. You can also specify the IP address to send to.

Example:

registrar = UDPRegistryClient()
list_of_servers = registrar.discover("foo")

Note

Consider using rpyc.utils.factory.discover() instead

discover(name)[source]

Sends a query for the specified service name.

Parameters:name – the service name (or one of its aliases)
Returns:a list of (host, port) tuples
register(aliases, port, interface='')[source]

Registers the given service aliases with the given TCP port. This API is intended to be called only by an RPyC server.

Parameters:
  • aliases – the service's aliases
  • port – the listening TCP port of the server
unregister(port)[source]

Unregisters the given RPyC server. This API is intended to be called only by an RPyC server.

Parameters:port – the listening TCP port of the RPyC server to unregister
class rpyc.utils.registry.TCPRegistryClient(ip, port=18811, timeout=2, logger=None)[source]

TCP-based registry client. You must specify the host (registry server) to connect to.

Example:

registrar = TCPRegistryClient("localhost")
list_of_servers = registrar.discover("foo")

Note

Consider using rpyc.utils.factory.discover() instead

discover(name)[source]

Sends a query for the specified service name.

Parameters:name – the service name (or one of its aliases)
Returns:a list of (host, port) tuples
register(aliases, port, interface='')[source]

Registers the given service aliases with the given TCP port. This API is intended to be called only by an RPyC server.

Parameters:
  • aliases – the service's aliases
  • port – the listening TCP port of the server
unregister(port)[source]

Unregisters the given RPyC server. This API is intended to be called only by an RPyC server.

Parameters:port – the listening TCP port of the RPyC server to unregister