Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from __future__ import print_function
import grpc
import bidirectional.bidirectional_pb2_grpc as bidirectional_pb2_grpc
import bidirectional.bidirectional_pb2 as bidirectional_pb2
def make_message(message):
return bidirectional_pb2.Message(
def generate_messages():
messages = [
make_message("First message"),
make_message("Second message"),
make_message("Third message"),
make_message("Fourth message"),
make_message("Fifth message"),
for msg in messages:
print("Hello Server Sending you the %s" % msg.message)
yield msg
def send_message(stub):
responses = stub.GetServerResponse(generate_messages())
for response in responses:
print("Hello from the server received your %s" % response.message)
def run():
with grpc.insecure_channel('localhost:50051') as channel:
stub = bidirectional_pb2_grpc.BidirectionalStub(channel)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment