| |
- __builtin__.object
-
- RpcConnection
- RpcRequest
- RpcResponse
- threading.Thread(threading._Verbose)
-
- PyRpc
class PyRpc(threading.Thread) |
|
PyRpc (threading.Thread)
Used by a class that wants to publish local methods and
functions for public availability. Runs as a thread.
By default a new PyRpc object uses the ipc protocol, which
is meant for processes running on the same host machine.
If you would like to export your services over tcp, you
can optionally specificy a tcpaddr ip:port to use.
Usage:
myRpc = PyRpc("com.myCompany.MyApplication") # can be any useful name
myRpc.publishService(myFunction)
myRpc.publishService(myFunction2)
myRpc.start() |
|
- Method resolution order:
- PyRpc
- threading.Thread
- threading._Verbose
- __builtin__.object
Methods defined here:
- __init__(self, name, tcpaddr=None, context=None)
- __init__(str name, str tcpaddr=None, Context content=None)
Create a new RPC object that can export services to clients.
str name - the name of this Application
str tcpaddr - if not None, should be a ip:port address (127.0.0.1:8000)
context - Optionally pass in another pyzmq Context
- publishService(self, method)
- publishService (object method)
Publishes the given callable, to be made available to
remote procedure calls.
- run(self)
- Not to be called directly. Use start()
- start(self)
- start()
Start the RPC server.
- stop(self)
- stop()
Stop the server thread process
Data descriptors defined here:
- services
- Property for returning the currently published services
Methods inherited from threading.Thread:
- __repr__(self)
- getName(self)
- isAlive(self)
- isDaemon(self)
- is_alive = isAlive(self)
- join(self, timeout=None)
- setDaemon(self, daemonic)
- setName(self, name)
Data descriptors inherited from threading.Thread:
- daemon
- ident
- name
Data descriptors inherited from threading._Verbose:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RpcConnection(__builtin__.object) |
|
RpcConnection
For making remote calls to published services in another
application (or even the same application). Uses multiple
worker threads to send out calls and process their
return values.
Usage:
def processResponse(rpcResponse):
print rpcResponse.result
rpc = PyRpc.RpcConnection("com.myCompany.MyApplication") # any useful name
rpc.call("myFunction", callback=processResponse, args=(1, "a"), kwargs={'flag':True, 'option':"blarg"}) |
|
Methods defined here:
- __del__(self)
- __init__(self, name, tcpaddr=None, context=None, workers=1)
- availableServices(self)
- availableServices() -> RpcResponse
Asks the remote server to tell us what services
are published.
Returns an RpcResponse object
- call(self, method, callback=None, async=False, args=[], kwargs={})
- call(str method, object callback=None, bool async=False, list args=[], dict kwargs={})
Make a remote call to the given service name, with an optional callback
and arguments to be used.
Can be run either blocking or asynchronously.
By default, this method blocks until a response is received.
If async=True, returns immediately with an empty RpcResponse. If a callback
was provided, it will be executed when the remote call returns a result.
- close(self)
- close()
Close the client connection
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RpcRequest(__builtin__.object) |
|
RpcRequest
Represents a request message to be sent out to a host
with published services. Used by RpcConnection when doing
calls. |
|
Methods defined here:
- __init__(self)
- __repr__(self)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- args
- async
- callback
- id
- kwargs
- method
Data and other attributes defined here:
- REQ_COUNT = 0
|
class RpcResponse(__builtin__.object) |
|
RpcResponse
Represents a response message from a remote call.
Wraps around the result from the remote call.
Used by splRpc when replying to a call from RpcConnection. |
|
Methods defined here:
- __init__(self, result=None, status=-1, error=None)
- __repr__(self)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- error
- result
- status
| |