Celery

API

twopi_flask_utils.celery.create_celery(name, config_obj, inject_version=True, **kwargs)

Creates a celery app.

Parameters:
  • config_obj – The configuration object to initiaze with
  • inject_version
    bool: Whether or not to inject the application’s
    version number. Attempts to get version number

    using twopi_flask_utils.deployment_release.get_release()

  • kwargs – Other arguments to pass to the Celery instantiation.
Returns:

An initialized celery application.

twopi_flask_utils.celery.create_db_session(celery)

Creates an SQLA Database scoped session. Requires SQLAlchemy.

Uses SQLALCHEMY_DATABASE_URI and SQLALCHEMY_POOL_RECYCLE to create an apropriate engine.

If you are using MySQL and SQLALCHEMY_POOL_RECYCLE is not specified, you’ll have a bad time - this is required, as MySQL kills old sessions.

Parameters:celery – The celery application to create the app on
Returns:A SQLAlchemy scoped_session instance.