c***@gmail.com
2018-02-14 22:45:42 UTC
I have a use-case which is similar to streaming RPC to a server written in
C++ - here is a simplified example:
# Setup a client and connect it to our task server
client = capnp.TwoPartyClient('localhost:8000')
task_mgr = client.bootstrap().cast_as(schema.Task)
class Notifier(schema.Notifier.Server):
def notify(self, params, **kwargs):
print "notifying"
task = task_mgr.create(type=0)
n = Notifier()
task.add_notifier(n).wait()
task.run().wait()
capnp.wait_forever()
The C++ server will kick off the task which will call the notifier's notify
asynchronously. The C++ client works as expected (I get notify callbacks
when the task wants to notify). The python client seems to be unable to
pump the message loop. I see an example with a threaded client which
involves repeatedly chaining promises to make something like this work, but
is there an easier way?
I was hoping that the capnp.wait_forever() would take care of pumping the
loop and executing any callbacks, similar to
my kj::NEVER_DONE.wait(client.getWaitScope()); in the C++ client...
C++ - here is a simplified example:
# Setup a client and connect it to our task server
client = capnp.TwoPartyClient('localhost:8000')
task_mgr = client.bootstrap().cast_as(schema.Task)
class Notifier(schema.Notifier.Server):
def notify(self, params, **kwargs):
print "notifying"
task = task_mgr.create(type=0)
n = Notifier()
task.add_notifier(n).wait()
task.run().wait()
capnp.wait_forever()
The C++ server will kick off the task which will call the notifier's notify
asynchronously. The C++ client works as expected (I get notify callbacks
when the task wants to notify). The python client seems to be unable to
pump the message loop. I see an example with a threaded client which
involves repeatedly chaining promises to make something like this work, but
is there an easier way?
I was hoping that the capnp.wait_forever() would take care of pumping the
loop and executing any callbacks, similar to
my kj::NEVER_DONE.wait(client.getWaitScope()); in the C++ client...
--
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
You received this message because you are subscribed to the Google Groups "Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capnproto+***@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.