Beispiel #1
0
def scheduler(queue):
    s = Scheduler(queue=queue)
    yield s
Beispiel #2
0
def __scheduler():
    return Scheduler(queue=queue, connection=connection)
Beispiel #3
0
def scheduler():
    with connection() as c:
        s = Scheduler(connection=c)
        s.clear_scheduler()
        yield s
        s.clear_scheduler()
Beispiel #4
0

# Add multiprocessing safeguards as recommended by
# https://docs.sqlalchemy.org/en/13/core/pooling.html#using-connection-pools-with-multiprocessing


@event.listens_for(connection, "connect")
def connect(dbapi_connection, connection_record):
    connection_record.info["pid"] = os.getpid()


@event.listens_for(connection, "checkout")
def checkout(dbapi_connection, connection_record, connection_proxy):
    pid = os.getpid()
    if connection_record.info["pid"] != pid:
        connection_record.connection = connection_proxy.connection = None
        raise exc.DisconnectionError(
            "Connection record belongs to pid %s, attempting to check out in pid %s"
            % (connection_record.info["pid"], pid)
        )


queue = Queue(app, connection=connection)

scheduler = Scheduler(queue=queue, connection=connection)


def initialize_worker():
    worker = Worker(app, connection=connection, num_workers=1)
    atexit.register(worker.shutdown)
Beispiel #5
0
def scheduler(queue):
    s = Scheduler(queue=queue)
    s.clear_scheduler()
    yield s
    s.clear_scheduler()