flask-celery

Celery integration for Flask (SINCE CELERY 3.0 THIS IS NO LONGER NEEDED)

  • 所有者: ask/flask-celery
  • 平台:
  • 許可證: BSD 3-Clause "New" or "Revised" License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

==============================
Flask <-> Celery Integration

:Version: 2.4.3

FROM CELERY 3.0 THIS LIBRARY IS NO LONGER NECESSARY, INSTEAD YOU SHOULD
USE THE STANDARD CELERY API

.. _Celery: http://celeryproject.org

Using Flask with Celery

From Celery 3.0 the Flask-Celery integration package is no longer
recommended and you should use the standard Celery API instead.

Please read the Celery getting started tutorial::

http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html

You can easily add Celery to your flask application like this:

myapp.py::

from celery import Celery

celery = Celery('myapp', broker='amqp://guest@localhost//')

@celery.task
def add(x, y):
    return x + y

To start the worker you can then launch the celery worker command
by pointing to your celery app instance::

$ celery -A myapp:celery worker -l info

See the commands help screen for more information::

$ celery help

If you want use the flask configuration as a source for the celery
configuration you can do that like this::

celery = Celery('myapp')
celery.conf.add_defaults(app.config)

If you need access to the request inside your task
then you can use the test context::

from flask import Flask
from celery import Celery

app = Flask('myapp')
celery = Celery('myapp')
celery.conf.add_defaults(app.config)

@celery.task
def hello():
    with app.test_request_context() as request:
        print('Hello {0!r}.format(request))

主要指標

概覽
名稱與所有者ask/flask-celery
主編程語言Python
編程語言Python (語言數: 1)
平台
許可證BSD 3-Clause "New" or "Revised" License
所有者活动
創建於2010-09-08 12:11:48
推送於2014-01-23 21:46:56
最后一次提交2014-01-23 21:46:56
發布數3
最新版本名稱v2.4.2 (發布於 )
第一版名稱v2.2.5 (發布於 )
用户参与
星數200
關注者數9
派生數34
提交數58
已啟用問題?
問題數20
打開的問題數10
拉請求數4
打開的拉請求數2
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?