Hi, so do you suggest to do this:
client.py
import grpc
import generated.bidirectional_pb2 as bid
def run():
channel = grpc.insecure_channel('localhost:50051')
stub = bid.SpeakStub(channel)
if __name__ == '__main__':
run()
server.py
def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
bid.add_SpeakServicer_to_server(bid.SpeakServicer(),server)
server.add_insecure_port('[::]:50051')
server.start()
print "[SERVER] start at 50051"
try:
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
except KeyboardInterrupt:
server.stop(0)
if __name__ == '__main__':
serve()
but I don’t get where I should implement the servicer
SpeakServicer(bid.BetaSpeakServicer) and how to invoke it for be that the
server send the message to the client.
Where the proto file is
service Speak {
rpc Message(stream Request) returns (stream Response){}
}
Can you help me?
Thanks
From: Nathaniel Manista <[email protected]>
Date: Thursday, July 28, 2016 at 9:43 PM
To: "Mosca, Federico" <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: Re: [grpc-io] gRPC - server client communication
On Thu, Jul 28, 2016 at 12:15 PM, Mosca, Federico
<[email protected]<mailto:[email protected]>> wrote:
yes I upgraded to latest python version of grpc (1.0.0rc1) but in all the
examples that I checked the scenario is the following:
- start server
- start client
- client send message to server that reply
(https://github.com/grpc/grpc/blob/846768c12ff03ea69073c9373ef211ef478c53d6/examples/python/helloworld/greeter_client.py#L42)
I need to create a scenario where is the server that send message to client
once both are up and running (as first that initiate the communication).
Maybe I'm missing something in the example/documentation, could you please
point me where to look?
I apologize; it had escaped me that our examples don't quite illustrate your
intended use. Two important things that gRPC does require are that the client
has to initiate communication with the server (by establishing a channel) and
that the client has to initiate the bidirectionally-streaming RPC. What is not
required is that the client send the first message. It's perfectly fine for the
server to send the first message. It's perfectly fine for the server to send
all its messages before the client sends any. It's perfectly fine for the
server to send all its messages and for the client to never send a single
message.
-N
--
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/19D4C577-97EF-4225-AD3B-15F5C1B66149%40here.com.
For more options, visit https://groups.google.com/d/optout.