Celery Bundle API¶
flask_unchained.bundles.celery
The Celery Bundle. |
flask_unchained.bundles.celery.config
Default configuration options for the Celery Bundle. |
flask_unchained.bundles.celery.extensions
The Celery extension. |
flask_unchained.bundles.celery.hooks
Discovers celery tasks. |
CeleryBundle¶
Config¶
-
class
flask_unchained.bundles.celery.config.
Config
[source]¶ Default configuration options for the Celery Bundle.
-
CELERY_BROKER_URL
= 'redis://127.0.0.1:6379/0'¶ The broker URL to connect to.
-
CELERY_RESULT_BACKEND
= 'redis://127.0.0.1:6379/0'¶ The result backend URL to connect to.
-
CELERY_ACCEPT_CONTENT
= ('json', 'pickle', 'dill')¶ Tuple of supported serialization strategies.
-
MAIL_SEND_FN
(to=None, template=None, **kwargs)¶ If the celery bundle is listed after the mail bundle in
unchained_config.BUNDLES
, then this configures the mail bundle to send emails asynchronously.
-
The Celery Extension¶
-
class
flask_unchained.bundles.celery.
Celery
(*args, **kwargs)[source]¶ The Celery extension:
from flask_unchained.bundles.celery import celery
-
task
(*args, **opts)[source]¶ Decorator to create a task class out of any callable.
See Task options for a list of the arguments that can be passed to this decorator.
- Examples:
@app.task def refresh_feed(url): store_feed(feedparser.parse(url))
with setting extra options:
@app.task(exchange='feeds') def refresh_feed(url): return store_feed(feedparser.parse(url))
- Note:
App Binding: For custom apps the task decorator will return a proxy object, so that the act of creating the task is not performed until the task is used or the task registry is accessed.
If you’re depending on binding to be deferred, then you must not access any attributes on the returned object until the application is fully set up (finalized).
-
DiscoverTasksHook¶
-
class
flask_unchained.bundles.celery.hooks.
DiscoverTasksHook
(unchained: flask_unchained.unchained.Unchained, bundle: Optional[flask_unchained.bundles.Bundle] = None)[source]¶ Discovers celery tasks.
-
name
: str = 'celery_tasks'¶ The name of this hook.
-
bundle_module_names
: Union[List[str], Tuple[str, ...], None] = ['tasks']¶ The default module this hook loads from.
Override by setting the
celery_tasks_module_names
attribute on your bundle class.
-