Update:the max_workers argument use default, use 'server.wait_for_termination()' to keep process alive

pull/19938/head
kerbalwzy 6 years ago
parent 151f596054
commit 55f1899d78
  1. 15
      examples/python/data_transmission/server.py

@ -1,4 +1,3 @@
import time
import grpc
from threading import Thread
@ -68,17 +67,21 @@ class DemoServer(demo_pb2_grpc.GRPCDemoServicer):
def main():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
server = grpc.server(futures.ThreadPoolExecutor())
demo_pb2_grpc.add_GRPCDemoServicer_to_server(DemoServer(), server)
server.add_insecure_port(SERVER_ADDRESS)
print("------------------start Python GRPC server")
server.start()
# In python3, `server` have no attribute `wait_for_termination`
while 1:
time.sleep(10)
server.wait_for_termination()
# If raise Error:
# AttributeError: '_Server' object has no attribute 'wait_for_termination'
# You can use the following code instead:
# import time
# while 1:
# time.sleep(10)
if __name__ == '__main__':

Loading…
Cancel
Save