Various fixups to the RPC api.
* change how restorer works * fix join_promises * add incref's all around to make sure we aren't freeing objects early * make it so we return PyPromises everywhere and make chains collapsible
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
# Copyright (c) 2013, Kenton Varda <temporal@gmail.com>
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@0xbdf87d7bb8304e81;
|
||||
$namespace("capnp::annotations");
|
||||
|
||||
annotation namespace(file): Text;
|
||||
@@ -6,7 +6,6 @@ import socket
|
||||
import capnp
|
||||
|
||||
import calculator_capnp
|
||||
import rpc_capnp
|
||||
|
||||
class PowerFunction(calculator_capnp.Calculator.Function.Server):
|
||||
'''An implementation of the Function interface wrapping pow(). Note that
|
||||
@@ -18,7 +17,7 @@ class PowerFunction(calculator_capnp.Calculator.Function.Server):
|
||||
return pow(params[0], params[1])
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser('Connects to the Calculator server at the given address and does some RPCs')
|
||||
parser = argparse.ArgumentParser(usage='Connects to the Calculator server at the given address and does some RPCs')
|
||||
parser.add_argument("host", help="HOST:PORT")
|
||||
|
||||
return parser.parse_args()
|
||||
@@ -27,7 +26,7 @@ def main():
|
||||
host, port = parse_args().host.split(':')
|
||||
|
||||
sock = socket.create_connection((host, port))
|
||||
client = capnp.RpcClient(sock)
|
||||
client = capnp.TwoPartyClient(sock)
|
||||
|
||||
# Pass "calculator" to ez_restore (there's also a `restore` function that takes a struct or AnyPointer as an argument), and then cast the returned capability to it's proper type. This casting is due to capabilities not having a reference to their schema
|
||||
calculator = client.ez_restore('calculator').cast_as(calculator_capnp.Calculator)
|
||||
|
||||
1251
examples/rpc.capnp
1251
examples/rpc.capnp
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user