Beispiel #1
0
def main():
    _setproctitle('structurarium.graph')
    parser = argparse.ArgumentParser(description='Run Structurarium graph server')
    parser.add_argument('--version', '-v', action='version', version=__version__)
    parser.add_argument('host')
    parser.add_argument('port', type=int)
    parser.add_argument('path')
    parser.add_argument('--authkey', '-k', action='store')
    parser.add_argument(
        '--worker',
        '-w',
        action='store',
        type=int,
        help='default is set to the number of CPU'
    )
    args = parser.parse_args()
    listener = Listener((args.host, args.port), family='AF_INET')
    database = Graph(args.path, authkey=args.authkey)
    pool = Pool(processes=args.worker)

    print 'Running on %s:%s' % (args.host, args.port)
    while True:
        connection = listener.accept()
        connection = reduce_connection(connection)
        # pool.apply_async(connect, [database, connection])
        connect(database, connection)
Beispiel #2
0
def main():
    _setproctitle('structurarium.taskqueue')
    parser = argparse.ArgumentParser(
        description='Run Structurarium graph server'
    )
    parser.add_argument(
        '--version',
        '-v',
        action='version',
        version=__version__
    )
    parser.add_argument('host')
    parser.add_argument('port', type=int)
    parser.add_argument('path')
    parser.add_argument('--authkey', '-k')
    parser.add_argument(
        '--worker',
        '-w',
        action='store',
        type=int,
        help='default is set to the number of CPU'
    )
    args = parser.parse_args()
    listener = Listener((args.host, args.port), family='AF_INET')
    database = TaskQueue(args.path, authkey=args.authkey)

    print 'Running on %s:%s' % (args.host, args.port)
    if args.worker > 1:
        pool = Pool(processes=args.worker)
        while True:
            pool = Pool(processes=args.worker)
            connection = listener.accept()
            connection = cPickle.dumps(reduce_connection(connection))
            database.process(connection)
            pool.apply_async(process, [database, connection])
    else:
        print 'monothread'
        database.replay()
        while True:
            connection = listener.accept()
            command = loads(connection.recv())
            output = database.play(command)
            connection.send(dumps(output))
            connection.close()