Example #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()
Example #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()
Example #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
Example #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
Example #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()
Example #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()
Example #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
Example #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
Example #9
0
def initialize_worker():
    worker = Worker(app, connection=connection, num_workers=1)
    atexit.register(worker.shutdown)