mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-23 19:49:43 +01:00
ce56953b24
* initial echo client/server examples * registered and unregistered versions of the example client * ignore pyc files * cpp echo code, flag to build examples * threaded server example
20 lines
462 B
Python
20 lines
462 B
Python
from grpc.beta import implementations
|
|
|
|
import echo_pb2
|
|
import time
|
|
|
|
class Echo(echo_pb2.BetaEchoServicer):
|
|
def DoEcho(self, request, context):
|
|
return echo_pb2.EchoRequest(message=request.message)
|
|
|
|
def main():
|
|
server = echo_pb2.beta_create_Echo_server(Echo())
|
|
server.add_insecure_port('[::]:50051')
|
|
server.start()
|
|
try:
|
|
time.sleep(600)
|
|
except KeyboardInterrupt:
|
|
server.stop(0)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|