Hi everyone, I hope you're doing goodie!

First, thanks a lot Kenton for all the magic! I want to use it! However, 
I'd like to use it from Python if possible hehe, but as you may know 
pycapnp is somewhat unmaintained (one thing I'd like to see it have is 
support for more than one client when wrapping a socket FD, or support for 
UDP connection strings somehow, maybe with udp: or something), and that's 
why I'm here instead - I'm probably misunderstanding how to use Capnp RPC 
more than anything else.

So, let's get to the point: I'm trying to learn how to use Capnp RPC in 
Python, so I made what seemed to me like one of the simplest things to do - 
a chat program. I managed to make it work with extremely poor network 
architecture where the client polls the server (several times per second) 
for new messages to be received. The code is here: 
https://github.com/Cheaterman/capnchat/ - the master branch still uses the 
"polling" protocol, while the "push_messages" branch attempts to push the 
messages directly to the client.

The issue happens here: 
https://github.com/Cheaterman/capnchat/blob/push_messages/server.py#L69 
(you probably already guessed I was trying something like that from the 
title), which attempts to wait on this promise 
<https://github.com/Cheaterman/capnchat/blob/push_messages/server.py#L119>, 
which corresponds to this part 
<https://github.com/Cheaterman/capnchat/blob/push_messages/chatroom.capnp#L23> 
of the proto (implemented here in the client 
<https://github.com/Cheaterman/capnchat/blob/push_messages/client.py#L70> - 
BTW I have no idea if having this ".Server" class on the client is a good 
idea).

As you already mentioned in other threads, the reason this doesn't work is 
because I can't make the main event loop wait for things (AIUI) because 
nothing would be processed in the meantime ; and callbacks are executed in 
the event loop. The problem is, if I don't wait() on that promise, it's 
never actually executed, so I don't quite know what I should be doing 
here... You also mentioned in other threads that I might want to add my 
promise to the TaskSet or something? I don't think this is exposed in 
Python, but I imagine wrapping it wouldn't be an issue (even with my 
limited knowledge of modern C++ and how to use it from Cython).

In any case, thanks in advance for clearing out any misunderstanding I may 
have as to how I am supposed to implement that kind of things. If things go 
well, I'd like to use Capnp RPC to implement a multiplayer games protocol, 
please tell me if that makes sense at all or if I should stop right there 
:-P

Thanks for reading!

-- 
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+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to