-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
32 lines (23 loc) · 695 Bytes
/
server.py
File metadata and controls
32 lines (23 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from concurrent import futures
import time
import grpc
import hello_pb2
import hello_pb2_grpc
import hello
class HelloServicer(hello_pb2_grpc.HelloServicer):
def Hello(self, request, context):
response = hello_pb2.HelloResponse()
response.value = hello.hello(request.value)
return response
def serve():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
hello_pb2_grpc.add_HelloServicer_to_server(HelloServicer(), server)
server.add_insecure_port('[::]:50051')
server.start()
try:
while True:
time.sleep(86400)
except KeyboardInterrupt:
server.stop(0)
if __name__ == '__main__':
serve()