Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 django-Q 做定时执行 #22

Merged
merged 2 commits into from
Dec 28, 2018
Merged

使用 django-Q 做定时执行 #22

merged 2 commits into from
Dec 28, 2018

Conversation

LeoQuote
Copy link
Collaborator

@LeoQuote LeoQuote commented Dec 27, 2018

需要在setting里配置redis地址, 其它的broker 比如 mongo 也可以, 详见文档

https://django-q.readthedocs.io/en/latest/configure.html

经测试计划任务会有大概20秒的延迟.

用户体验上, 建议在选时间时, 给出几个特定时间点的按钮, 比如 2 分钟后, 3 分钟后, 10 分钟后, 下一个整点, 最后加一个选自定义时间的按钮, 这样基本可以用点击按钮覆盖所有需求

选时间时,应该只精确到分, 因为毕竟有延时, 如果精确到秒却没有执行显得是我们系统不靠谱.

启动的时候需要额外 python manage.py qcluster 启动执行进程
Copy link
Owner

@hhyo hhyo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既然用了redis,可以考虑把CACHES也换掉,参考https://github.com/niwinz/django-redis

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://127.0.0.1:6379/1",
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
        }
    }
}

同时索性把django-apscheduler依赖删除,明天我也验证下,赞!

@hhyo hhyo merged commit 8649862 into hhyo:master Dec 28, 2018
@hhyo hhyo mentioned this pull request Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants