Ejemplo n.º 1
0
def new_server(sender, address, port):
    """ 新建服务
    """
    sender.future_list()
    server = grpc.server(AsyncioExecutor(loop=sender.loop))
    wallet_pb2_grpc.add_WalletServicer_to_server(WalletServicer(sender),
                                                 server)
    server.add_insecure_port(address + ':' + str(port))
    return server
Ejemplo n.º 2
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    service.add_WalletServicer_to_server(WalletService(), server)
    server.add_insecure_port('127.0.0.1:50052')
    server.start()
    try:
        while True:
            time.sleep(_ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        print('Srever Stop')
        server.stop(0)
Ejemplo n.º 3
0
def run(host, port):
    '''
    Run the GRPC server
    '''
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=1))
    wallet_pb2_grpc.add_WalletServicer_to_server(WalletServicer(), server)
    server.add_insecure_port('%s:%d' % (host, port))
    server.start()

    try:
        while True:
            print("Server started at...%d" % port)
            time.sleep(_ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        server.stop(0)