Last active
January 30, 2024 11:15
-
-
Save rmsaitam/e1f96e7ded754f71357d2fd2e0facfd6 to your computer and use it in GitHub Desktop.
Servidor GRPC
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 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