Esempio n. 1
0
def worker():
    with connection() as c:
        b = Worker(QUEUE, c)
        b.storage.clear(force=True)
        yield b
        b.storage.clear(force=True)
        b.shutdown()
Esempio n. 2
0
def inmem_queue():
    with connection() as conn:
        e = Worker(queues="pytest", connection=conn)
        c = Queue(queue="pytest", connection=conn)
        c.e = e
        c.storage.clear(force=True)
        yield c
        e.shutdown()
Esempio n. 3
0
def initialize_workers():
    regular_worker = Worker(task_queue_name,
                            connection=connection,
                            num_workers=1)
    priority_worker = Worker(priority_queue_name,
                             connection=connection,
                             num_workers=3)
    return regular_worker, priority_worker
Esempio n. 4
0
def initialize_workers():
    logger.info("Starting scheduler workers.")
    regular_worker = Worker(task_queue_name,
                            connection=connection,
                            num_workers=1)
    priority_worker = Worker(priority_queue_name,
                             connection=connection,
                             num_workers=3)
    return regular_worker, priority_worker
Esempio n. 5
0
def worker():
    with tempfile.NamedTemporaryFile() as f:
        connection = create_engine(
            "sqlite:///{path}".format(path=f.name),
            connect_args={"check_same_thread": False},
            poolclass=NullPool,
        )
        b = Worker(QUEUE, connection)
        yield b
        b.shutdown()
Esempio n. 6
0
def inmem_queue():
    with tempfile.NamedTemporaryFile() as f:
        connection = create_engine(
            "sqlite:///{path}".format(path=f.name),
            connect_args={"check_same_thread": False},
            poolclass=NullPool,
        )
        e = Worker(queues="pytest", connection=connection)
        c = Queue(queue="pytest", connection=connection)
        c.e = e
        yield c
        e.shutdown()
Esempio n. 7
0
def worker():
    _, filepath = tempfile.mkstemp()
    connection = create_engine(
        "sqlite:///{path}".format(path=filepath),
        connect_args={"check_same_thread": False},
        poolclass=NullPool,
    )
    b = Worker(QUEUE, connection)
    yield b
    b.shutdown()
    try:
        os.remove(filepath)
    except OSError:
        pass
Esempio n. 8
0
def inmem_queue():
    fd, filepath = tempfile.mkstemp()
    connection = create_engine(
        "sqlite:///{path}".format(path=filepath),
        connect_args={"check_same_thread": False},
        poolclass=NullPool,
    )
    e = Worker(queues="pytest", connection=connection)
    c = Queue(queue="pytest", connection=connection)
    c.e = e
    yield c
    e.shutdown()
    os.close(fd)
    try:
        os.remove(filepath)
    except OSError:
        pass
Esempio n. 9
0
def initialize_worker():
    worker = Worker(app, connection=connection, num_workers=1)
    atexit.register(worker.shutdown)