示例#1
0
def worker(i):
    print "worker", i

    server_pool = pools.Pool(create=lambda: couchdb.Server(options.COUCHDB_URI), max_size=15)

    with server_pool.item() as server:
        while True:
            db = common.get_db(server, "app2")
            uuids = common.UUIDsIterator(server)

            print "worker", i, "create"
            common.create_docs(db, options.NUM_DOCS, uuids)
            eventlet.sleep(random.uniform(0.1, 3))

            # Delete some random docs
            common.delete_random(db, common.random_rows(db, 10), i)
            eventlet.sleep(random.uniform(0.1, 3))
示例#2
0
def main():
    # wait for couchdb to start
    time.sleep(2)

    couch = couchdb.Server(options.COUCHDB_URI)
    db = common.get_db(couch, 'app1')

    uuids = common.UUIDsIterator(couch)

    while True:
        # Create docs until there are options.NUM_DOCS docs in the DB
        print 'Create docs'
        common.create_docs(db, options.NUM_DOCS, uuids)
        time.sleep(2)

        # Delete some random docs
        common.delete_random(db, common.random_rows(db, 10), 1)
        time.sleep(2)
示例#3
0
def worker(ctx, i):
    print 'worker', i

    skt = ctx.socket(zmq.XREQ)
    skt.connect("inproc://#1")

    server_pool = pools.Pool(create=lambda: couchdb.Server(options.COUCHDB_URI), max_size=15)


    with server_pool.item() as server:
        while True:
            db = common.get_db(server, 'app3')
            uuids = common.UUIDsIterator(server)

            print 'worker', i, 'create'
            common.create_docs(db, options.NUM_DOCS, uuids)
            eventlet.sleep(random.uniform(0.1, 3))

            # Delete some random docs
            rows = common.random_rows(db, 10)
            for row in rows:
                skt.send_multipart(['', json.dumps(row)])

            eventlet.sleep(random.uniform(0.1, 3))