跳转到主要内容

``pq``的django包装器

项目描述

pq的django包装器。

https://travis-ci.org/jeanphix/dj-pq.svg?branch=master

安装

pip install dj-pq

配置

dj_pq添加到您的INSTALLED_APPS

INSTALLED_APPS += [
    'dj_pq',
]

应用迁移

./manage.py migrate

使用

dj-pq公开了pq任务API

from dj_pq import get_queue

queue = get_queue('notifications')

@queue.task()
def notify(user_id):
    User.objects.get(id=user_id).notify()

notify(42)

可选地,可以将一个队列绑定到特定的数据库连接

queue = get_queue('notifications', 'another_connection')

一个worker命令允许启动特定队列的工作进程

./manage.py worker notifications

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页