Skip to content

Instantly share code, notes, and snippets.

@pfreixes
Last active January 1, 2020 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfreixes/08086d17fe8357b1b75cee5aac20d561 to your computer and use it in GitHub Desktop.
Save pfreixes/08086d17fe8357b1b75cee5aac20d561 to your computer and use it in GitHub Desktop.
import asyncio
import grpc
from grpc.experimental import aio
from proto import echo_pb2
from proto import echo_pb2_grpc
async def run_sync_request(loop):
aio.init_grpc_aio()
channel = grpc.insecure_channel("127.0.0.1:50051")
stub = echo_pb2_grpc.EchoStub(channel)
response = stub.Hi(echo_pb2.EchoRequest(message="ping"))
assert response
print("eureka")
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(run_sync_request(loop))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment