RPyC

RPyC

RPyC (pronounced "are-pie-see"), or Remote Python Call, is a python library for remote procedure calls (RPC), as well as distributed computing. Unlike regular RPC mechanisms, such as ONC RPC, CORBA or Java RMI, RPyC is transparent, symmetrical, and requires no special decoration or definition languages. Moreover, it provides programmatic access to any pythonic element, be it functions, classes, instances or modules.

The current release is 2.60.

Features

* Symmetrical -- there is no difference between the client and the server -- both can serve. The only different aspect is that the client is usually the side that initiates the action. Being symmetrical, for example, allows the client to pass callback functions to the server.
* Transparent -- remote objects look and behave the same as local objects would.
* Exceptions propagate like local ones
* Allows for synchronous and asynchronous operation:
** Synchronous operations return a "NetProxy" (see below)
** Asynchronous operations return an AsyncResult, which is like promise objects
** AsyncResults can be used as events
* Threads are supported (though not recommended)
* UNIX specific: server integration with inetd

Architecture

RPyC gives the programmer a slave python interpreter at his or her control. In this essence, RPyC is different than other RPCs, that require registration of resources prior to accessing them. As a result, using RPyC is much more straight-forward, but this comes at the expense of security (you cannot limit access). RPyC is intended to be used within a trusted network, there are various schemes including VPN for achieving this.

Once a client is connected to the server, it has one of two ways to perform remote operations:
* The "modules" property, that exposes the server's modules namespace doc = conn.modules.xml.dom.minidom.parseString("xml")
* The "execute" function, that executes the given code on the server conn.execute("print 'hello world'")

Remote operations return something called a "NetProxy", which is an intermediate object that reflects any operation performed locally on it to the remote object. For example, conn.modules.sys.path is a NetProxy for the sys.path object of the server. Any local changes done to conn.modules.sys.path are reflected immediately on the remote object.Note: NetProxies are not used for "simple objects", such as numbers and strings, which are immutable.

"Async" is a proxy wrapper, meaning, it takes a NetProxy and returns another that wraps it with asynchronous functionallity. Operations done to an AsyncNetProxy return something called AsyncResult. These objects have a '.is_ready' predicate, '.result' property that holds the result (or blocks until it arrives), and '.on_ready' callback, which will be called when the result arrives.

Usage

Originally, RPyC was developed for managing distributed testing of products over a range of different platforms (all capable of running python). However, RPyC has evolved since then, and now its use cases include:
* Distributed computing (splitting workload between machines)
* Distributed testing (running tests that connect multiple platforms and abstracting hardware resources)
* Remote administration (tweaking config files from one central place, etc)
* Tunneling or chaining (crossing over routable network boundaries)

Demo

# you need to start server on "somehost"! for example: python threaded_server.py

from Rpyc import SocketConnectionconn = SocketConnection("somehost") print conn.modules.sys.pathconn.modules.sys.path.append("lucy")print conn.modules.sys.path [-1] def remote_ls (conn, path): print "size user name" ros = conn.modules.os for filename in ros.listdir(path): stats = ros.stat (ros.path.join(path, filename)) print "%d %d %s" % (stats.st_size, stats.st_uid, filename) remote_ls (conn, "/home")
# and exceptions...try: f = conn.modules.__builtin__.open ("//\some invalid-filename/:/:?/")except IOError: pass

History

RPyC is based on the work of Eyal Lotem (aka Lotex) on PyInvoke, which is no longer maintained. The first public release was 1.20, which allowed for symmetrical and transparent RPC, but not for asynchronous operation. Version 1.6, while never publicly released, added the concept of 'events', as a means for the server to inform the client. Version 2.X, the first release of which was 2.2, added thread synchronization and the "Async" concept, which can be used as a superset of events. Version 2.40 adds the "execute" method, that can be used to execute code on the other side of the connection directly.

External links

* [http://rpyc.wikispaces.com/ RPyC project page]
* [http://pybuild.sourceforge.net/pyinvoke.html PyInvoke]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Royal Perth Yacht Club — The Royal Perth Yacht Club (RPYC) is a yacht club in Perth, Western Australia. This club staged the unsuccessful 1987 America s Cup defence at Fremantle following the 1983 victory at Newport, USA, of Australia II mdash;ending the New York Yacht… …   Wikipedia

  • Copa América (regata) — Para otros usos de este término, véase Copa América (desambiguación). Trofeo de la Copa América de vela La Copa América, Copa del América o Copa de la América (America s Cup en inglés y oficialmente) de Vela es la competición más importante de… …   Wikipedia Español

  • Wind (Film) — Filmdaten Deutscher Titel Wind Produktionsland USA …   Deutsch Wikipedia

  • Real Club de Yates de Perth — Saltar a navegación, búsqueda Real Club de Yates de Perth Royal Perth Yacht Club Grímpola …   Wikipedia Español

  • Remote procedure call — (RPC) is an Inter process communication technology that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding… …   Wikipedia

  • List of distributed computing projects — A list of distributed computing projects. Berkeley Open Infrastructure for Network Computing (BOINC) The Berkeley Open Infrastructure for Network Computing (BOINC) platform is currently the most popular volunteer based distributed computing… …   Wikipedia

  • Nava Applebaum — Nava (or Naava)[1] Applebaum (also spelled Appelbaum)[2] (c. 1983 – September 9, 2003)[3] was a 20 year old Israeli American woman who was murdered together with her father on the evening before her wedding by a Palestinian suicide bomber.… …   Wikipedia

  • Comparison of cluster software — The following tables compare general and technical information for notable computer cluster software. This article is not all inclusive and may become out of date quickly. Those software can be grossly separated in 4 categories: Job scheduler,… …   Wikipedia

  • Remote Procedure Call — (RPC, sinngemäß „Aufruf einer fernen Prozedur“) ist eine Technik zur Realisierung von Interprozesskommunikation. Sie ermöglicht den Aufruf von Funktionen in anderen Adressräumen. Im Normalfall werden die aufgerufenen Funktionen auf einem anderen… …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”