Skip to content

Instantly share code, notes, and snippets.

@rmsaitam
Last active January 30, 2024 11:15
Show Gist options
  • Save rmsaitam/e1f96e7ded754f71357d2fd2e0facfd6 to your computer and use it in GitHub Desktop.
Save rmsaitam/e1f96e7ded754f71357d2fd2e0facfd6 to your computer and use it in GitHub Desktop.
Servidor GRPC
import grpc
from concurrent import futures
import examplo_pb2
import examplo_pb2_grpc
class GreeterServicer(examplo_pb2_grpc.GreeterServicer):
def SayHello(self, request, context):
return examplo_pb2.HelloResponse(greeting=f"Hello, {request.name}!")
def run_server():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
examplp_pb2_grpc.add_GreeterServicer_to_server(GreeterServicer(), server)
server.add_insecure_port("[::]:50051")
server.start()
server.wait_for_termination()
if __name__ == "__main__":
run_server()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment