rpyc_mem.service package
Submodules
rpyc_mem.service.rpyc_mem_service module
RPyC Memory Service
- class rpyc_mem.service.rpyc_mem_service.RpycMemService(hostname=None, port=None, *args, **kwargs)
Bases:
rpyc.core.service.ServiceRPyC memory service provides functionality to create named and unnamed python objects on remote hosts (one which runs this service). The remote objects are created using remote modules (see
remote_import). By default all objects created are unnamed, they can be mapped against unique_key to make them named. named objects can be managed using unique_key. This service is intended to be run withrpyc.utils.server.ThreadingServeror variants of it to maintain one snapshot of the memory- Parameters
hostname (str) – Hostname on which the service is run. Runs on
0.0.0.0by default.port (int) – Port on which the service is run. Picks a random by default. Can be queried back with
self.server_obj.port(this is available only when the service is ran).args – Left for
RPyCduringServiceinitializationkwargs – Left for
RPyCduringServiceinitialization
- run(server=None, server_kwargs=None)
Run the RPyC memory service. The
hostandportused are picked from the__init__configuration. By defaultThreadingServeris used, however this can be altered by passing differentserverand associatedserver_kwargs.- Parameters
server – The server to use for running the service.
server_kwargs – Update the default server arguments with these.
- Returns
- classmethod memoize(unique_key, robj=<object object>, robj_gen=<object object>)
Memoize the mapping of remote object or remote object returned by the generator against the unique_key
- Parameters
unique_key – The unique_key for creating/querying the mapping
robj (Any) – The remote object for memoization (One among
robj,robj_genshould be passed)robj_gen (Callable) – The remote object generator for memoization (One among
robj,robj_genshould be passed)
- Returns
The memoized object
- classmethod get(unique_key)
Get the remote object against the unique_key. Raise an exception if the mapping is not present
- Parameters
unique_key – The unique_key for querying the mapping
- Returns
The memoized object
- classmethod update(unique_key, robj=<object object>, robj_gen=<object object>)
Update the mapping with the remote object or remote object returned by the generator against the unique_key (create new mapping if it doesnt exist)
- Parameters
unique_key – The unique_key for updating the mapping
robj (Any) – The remote object for update (One among
robj,robj_genshould be passed)robj_gen (Callable) – The remote object generator for update (One among
robj,robj_genshould be passed)
- Returns
The updated object
- classmethod delete(unique_key)
Delete the mapping against the unique_key. Raise an exception if the mapping is not present
- Parameters
unique_key – The unique_key for deleting the mapping
- Returns
- classmethod is_memoized(unique_key)
Return
Trueif a mapping exists against the unique_key- Parameters
unique_key – The unique_key for querying the mapping
- Returns
- classmethod remote_import(module, package=None)
Make remote modules available to the clients, primarily for creating remote objects
- Parameters
module (str) – The module to import in absolute or relative terms (Ex: pkg.mod, ..mod)
package (str) – The package which acts as a base for resolving the module (should be set when relative imports are used)
- Returns
Remote module
- classmethod rpyc_version()
Return
RPyCversion of the server- Returns