celery笔记
安装:pip install celery==4.1.0(django==1.11, redis==2.10.6, django-redis==4.4.0, kombu==4.1.0)
执行异步任务命令(二选一):
celery -A celery_task.task worker --pool=solo -l info
celery -A celery_task.task worker -l info
执行定时任务命令(需要登录后台管理页面添加任务):
celery -A celery_task.task worker -l info
保存结果需安装:django-celery-results==1.0.4
Issues with mysql
If you want to run django-celery-results with MySQL, you might run into some issues.
One such issue is when you try to run python manage.py migrate django_celery_results, you might get the following error:
django.db.utils.OperationalError: (1071, 'Specified key was too long; max key length is 767 bytes')
To get around this issue, you can set:
DJANGO_CELERY_RESULTS_TASK_ID_MAX_LENGTH=191
(or any other value if any other db other than MySQL is causing similar issues.)
max_length of 191 seems to work for MySQL.
window开启mysql远程访问方法:
1、放通3306端口,防火墙添加入站规则
2、user表127.0.0.1改为%
3、flush privileges;
mysql设置时区:set global time_zone = '+8:00';