eval()
, since this again enables the execution of arbitrary statements.
rpyc.Service
.
on_connect()
and on_disconnect()
methods enable the initialization and resource approval upon creation/removal of the service instance.
exposed_
prefix.
import rpyc import time class EchoService(rpyc.Service): def on_connect(self): pass def on_disconnect(self): pass def exposed_echo(self, somevalue): return somevalue def exposed_long_echo(self, somevalue): time.sleep(30) # simulate a longer calculation... return somevalue
csrpc.core.registration
module:
def get_service_directory(): """Returns the service directory""" def get_service(name): """Returns the service, which is registered under [name]; throws ServiceDirectoryError if the key [name] is not available""" def register_service(name, service=None): """Registers the service defined by the class [service] under the name [name]; throws ServiceDirectoryError in the case of conflict""" def access_service(name): """Establishes a connection to the service remotely registered under [name]; equates to call of register_service(name)""" def deregister_service(name): """Removes service/connection from the directory; throws ServiceDirectoryError if the key [name] is not available"""
from csrpc.core import registration from csrpc.core.exceptions import ServiceDirectoryError try: sr = registration.access_service('service_registration') except ServiceDirectoryError: sr = registration.get_service('service_registration')
sr.root.register('examples.echo_service', 'csrpc.services.examples.EchoServer')
echo_service = registration.access_service('examples.echo_service')
root
of the local representation
result = echo_service.root.echo('hello world')
import rpyc alongecho = rpyc.async(echo_service.root.long_echo) res = alongecho('A really long calculation')