Skip to content

Instantly share code, notes, and snippets.

Created June 26, 2020 12:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save velotiotech/3e6812a7277cc765dde2e4c77a707a67 to your computer and use it in GitHub Desktop.
import grpc
from concurrent import futures
import time
import unary.unary_pb2_grpc as pb2_grpc
import unary.unary_pb2 as pb2
class UnaryService(pb2_grpc.UnaryServicer):
def __init__(self, *args, **kwargs):
def GetServerResponse(self, request, context):
# get the string from the incoming request
message = request.message
result = f'Hello I am up and running received "{message}" message from you'
result = {'message': result, 'received': True}
return pb2.MessageResponse(**result)
def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
pb2_grpc.add_UnaryServicer_to_server(UnaryService(), server)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment