加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

【Python分布式】Celery安装及使用

发布时间:2020-12-17 01:22:44 所属栏目:Python 来源:网络整理
导读: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','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、调度任务

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读