Skip to content

Instantly share code, notes, and snippets.

@ashish-mj
Created May 4, 2024 17:20
Show Gist options
  • Save ashish-mj/a0ea39dbd1342aef1dfd90185758738f to your computer and use it in GitHub Desktop.
Save ashish-mj/a0ea39dbd1342aef1dfd90185758738f to your computer and use it in GitHub Desktop.
from concurrent import futures
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
class Greeter(helloworld_pb2_grpc.GreeterServicer):
def SayHello(self, request, context):
return helloworld_pb2.HelloReply(message="Hello, %s!" % request.name)
def run():
port = "50051"
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server)
server.add_insecure_port("[::]:" + port)
server.start()
server.wait_for_termination()
if __name__ == "__main__":
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment