Created
April 13, 2022 12:51
-
-
Save harryscholes/d42bbd90e367fa04fb4bb568ff51e207 to your computer and use it in GitHub Desktop.
Python asyncio gRPC client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import grpc | |
from recommender_pb2_grpc import RecommenderStub | |
from recommender_pb2 import RecommendRequest | |
async def run() -> None: | |
async with grpc.aio.insecure_channel('localhost:50051') as channel: | |
client = RecommenderStub(channel) | |
request = RecommendRequest() | |
request.tmdb_ids.extend([ | |
44214, # Black Swan | |
641, # Requiem for a Dream | |
]) | |
response = await client.Recommend(request) | |
print(response.recommendations) | |
if __name__ == '__main__': | |
asyncio.run(run()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment