On Fri, Jul 29, 2016 at 10:02 AM, Mosca, Federico <[email protected]> wrote:
> What is not so clear is if after the client call stub.message the server > only 'reply' to that using the stream response and nothing else, is it > correct? > Correct. Sever can not start a new exchanges of request/response to the client, > right? > Correct. What we would like to do is: > -client invoke the rpc (there is no other way I understood) > -server ask something to the client > -client do something somewhere else and return result to the server > Is it doable? > This is doable and it will take just a little bit of control-flow gymnastics. It's perfectly fine for the client to invoke an RPC, the server to send a response, and then for the client to send a request (the names "request" and "response" are only used to identify the direction in which a message travels during the RPC, not whether it is sent before or after any other message). But it is the case that on the client-side an iterator of request messages must be passed at RPC invocation. What I think you will have to do, then, is write your own object that implements the iterator protocol <https://docs.python.org/2/library/stdtypes.html#iterator-types> but that does not emit a request object until after other code on the client-side has received a response (or many responses; up to you) and determined from that response (or those responses) the value of the request to send to the server. Then you can pass that object at RPC invocation; the client-side runtime will immediately ask it for a request value (by calling its next (Python 2) or __next__ (Python 3) method), but it won't actually return from that call until much later (after all the responses have been received). How much do you like working with condition variables, events, blocking queues, and the like? -Nathaniel -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAEOYnARzbnKbdmZixWKcQt3hAka%3DOZ29CD49_1Rus%3D5rzF49zw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
