RPyC
Symmetric, transparent remote procedure calls for Python.
Last updated
RPyC (Remote Python Call) is a Python library for remote procedure calls and distributed computing. It is notable for being transparent and symmetric, requiring no special decoration or definition languages. The library provides programmatic access to any Python element, including functions, classes, instances, and modules.
History
RPyC traces its origins to PyInvoke, a project by Eyal Lotem (Lotex) that is now abandoned. Its initial public version, 1.20, enabled symmetric and transparent remote procedure calls but lacked asynchronous support. An unreleased version, 1.6, introduced events for server-to-client communication.
The 2.X series, beginning with 2.2, brought thread synchronization and the Async feature, which could replace events entirely. Version 2.40 added the execute method, allowing direct code execution on the remote side. The library was fully rewritten as RPyC 3, which introduced a capability-based security model, explicit services, and several other enhancements.
Features
RPyC is symmetric, meaning there is no difference between client and server; both can serve, though the client typically initiates the action. This symmetry allows the client to pass callback functions to the server. Remote objects are transparent, behaving like local objects, and exceptions propagate as local ones. The library supports both synchronous operations, which return a NetProxy, and asynchronous operations, which return an AsyncResult similar to promise objects.
AsyncResults can be used as events. Threads are supported but not recommended. On UNIX systems, server integration with inetd is available.
Architecture
RPyC gives the programmer control over a slave Python interpreter, differing from other RPCs that require resource registration before access. This makes usage straightforward but reduces security, as access cannot be limited; RPyC is intended for trusted networks, with VPN among the schemes for achieving this. Once connected, a client can perform remote operations via the modules property, which exposes the server's modules namespace (e.g., conn.modules.sys.path), or via the execute function, which runs code on the server (e.g., conn.execute("print 'hello world'")).
Remote operations return a NetProxy, an intermediate object that reflects local operations onto the remote object; changes to a NetProxy are immediately reflected remotely. Simple immutable objects like numbers and strings do not use NetProxies. Async is a proxy wrapper that takes a NetProxy and returns an AsyncNetProxy; operations on it yield an AsyncResult, which has an is_ready predicate, a result property (blocking until the result arrives), and an on_ready callback.
More in Python Libraries
Sources
Compiled from Wikipedia and the sources listed below. Text from Wikipedia is available under CC BY-SA 4.0; this entry is adapted from it.
- Wikipedia: RPyC (CC BY-SA 4.0).
Spotted an error? Know more?
Reader corrections go straight into our review queue. Suggest an edit · How this site is sourced
