Пример #1
0
    host=config.REDIS_HOST,
    port=config.REDIS_PORT,
    password=config.REDIS_PASSWORD,
    **redis_kwargs,
)
huey = RedisHuey(connection_pool=connection_pool)

# these two lines need to be here so we can define [non]retriable_task
huey.flask_app = Flask(__name__)
huey.flask_app.config.from_object(config)

# this line is so this all works the same in tests
db.init_app(huey.flask_app)

# Normal task, no retries
nonretriable_task = huey.context_task(huey.flask_app.app_context())

# These tasks retry every 10 minutes for four hours.
retriable_task = huey.context_task(huey.flask_app.app_context(),
                                   retries=6 * 4,
                                   retry_delay=10 * 60)


@huey.on_startup()
def create_app():
    app = Flask(__name__)
    app.config.from_object(config)
    huey.flask_app = app
    db.init_app(app)