<p style="font-family:'-apple-system','SF UI Text',Arial,'PingFang SC','Hiragino Sans GB','Microsoft YaHei','WenQuanYi Micro Hei',sans-serif,SimHei,SimSun;background-color:rgb(255,255,255);"><span style="font-size:18px;">一、Celery在windows下安装步骤
<p style="font-family:'-apple-system',255);"><span style="font-size:18px;">1、打开终端输入命令<pre style="white-space:pre-wrap;font-size:14px;line-height:22px;background-color:rgb(255,255);"><code class="language-python hljs"><span class="space" style="text-indent:2em;line-height:inherit;"> pip install celery==<span class="hljs-number">3.1<span class="hljs-number">.25 <p style="font-family:'-apple-system',255);"><span style="font-size:18px;">2、查看完整可用命令选项<pre style="white-space:pre-wrap;font-size:14px;line-height:22px;background-color:rgb(255,255);"><code class="language-python hljs">celery worker --help<p style="font-family:'-apple-system',255);"><span style="font-size:18px;">3、创建一个celery application项目作为任务列表,打开pycharm应用,创建应用,然后创建后运行tasks.py文件,虽然运行不报错,其实它并没有启动woker。<p style="font-family:'-apple-system',255);"><span style="font-size:18px;"><p style="font-family:'-apple-system',255);"><span style="font-size:18px;">4、启动Celery worker进行监听并执行任务,切换到终端<pre style="white-space:pre-wrap;font-size:14px;line-height:22px;background-color:rgb(255,255);"><code class="language-python hljs">celery -A tasks worker --loglevel=info<span style="color:rgb(51,51,51);font-family:'-apple-system',SimSun;font-size:14px;background-color:rgb(255,255);">打开终端后,切换到tasks.py文件所在目录,然后输入上面的命令<p style="font-family:'-apple-system',255);"><span style="font-size:18px;">
<p style="font-family:'-apple-system',255);">注意:若不切换到task.py文件,会报错找不到这个文件,下面是运行正确的结果<p style="font-family:'-apple-system',255);"><div style="color:rgb(51,255);"><span style="font-size:18px;">5、调度任务 原文链接:https://www.f2er.com/python/59332.html