Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
The Proto! Python Async RPC based on Protobufers and TCP sokets.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
debian
proto
README.debian
README.md
client.py
ez_setup.py
sample.proto
server.py
serverd.py
setup.cfg
setup.py
speedtest.py

README.md

The Proto! Python Async RPC based on ProtocolBuffers and TCP sockets.

The Proto is a simple RPC implementation on top of ProtocolBuffers rpc stubs. It uses TCP sockets to talk and ASN.1 to encode packets with your ProtocolBuffer message & some meta data for rpc.

Based on:

Current version: 0.4.0

Server Sample

Before using this RPC module you need to create a protocol file and generate python stubs and classes. ./protoc -python_out=. myprotocolfile.proto So your 'myprotocolfile' will become myprotocolfile_pb2.py module. You should supply it to 'run_server' method of your rpc server implementation. See server.py for reference. You need to:

  • Subclass ProtoServer and generated server class (MyRPCServer is example)

    class MyRPCServerImpl(ProtoServer, MyRPCServer): def init(self, addr): ProtoServer.init(self, addr)

  • import your generated module. import myprotocolfile_pb2

  • start server MyRPCServerImpl.run_server(port = 9999, pb2 = myprotocolfile_pb2)

Client Sample

See client.py for working example

from myprotocolfile_pb2 import MyRequestClass
rpc_server = MyRPCServer_Stub(ProtoChannel('localhost', 9999, pb2))
controller = ProtoController()
try:
  r = MyRequestClass()
  response  = rpc_server.my_rpc_method(controller, r, None)
  if response: print 'response %s' % str(response)
except ProtoError, pe:
  print 'ProtoError:', str(pe)
Something went wrong with that request. Please try again.