Python-celery的使用
安装:pip install celery
pip install eventlet
需要提前安装redis。
(Download, extract and compile Redis with:
$ wget http://download.redis.io/releases/redis-4.0.11.tar.gz
$ tar xzf redis-4.0.11.tar.gz
$ cd redis-4.0.11
$ make
The binaries
that are now compiled are available in the src directory.
Run Redis with:
启动服务
$
src/redis-server
You can
interact with Redis using the built-in client:
)
运行redis,rebitmq或者其他。src/redis-server
redis.conf 利用配置文件执行,配置文件内修改ip和端口
创建一个tasks.py文件。
from celery import Celery
import time
app = Celery('tasks', broker='redis://192.168.118.130:6379/0',
backend="redis://192.168.118.130:6379/0")
@app.task
def send_mail():
print('hello world')
创建一个需要执行的文件。T1.py
from tasks import send_mail
if __name__ == '__main__':
send_mail.delay() #括号里面可以放参数,把要要发送的邮件的地址放进去。
pycharm里面命令行执行:
celery -A tasks worker --loglevel=info -P eventlet
执行需要执行的文件,然后会收到相关问题。返回的问题等。
send_mail.delay() 可以送参数,把参数直接放进去。邮箱地址。

Python-celery的使用的更多相关文章
- python celery + redis
redis http://debugo.com/python-redis celery http://docs.jinkan.org/docs/celery/getting-started/intro ...
- python celery多worker、多队列、定时任务
python celery多worker.多队列.定时任务
- python—Celery异步分布式
python—Celery异步分布式 Celery 是一个python开发的异步分布式任务调度模块,是一个消息传输的中间件,可以理解为一个邮箱,每当应用程序调用celery的异步任务时,会向brok ...
- Python Celery队列
Celery队列简介: Celery 是一个 基于python开发的分布式异步消息任务队列,通过它可以轻松的实现任务的异步处理, 如果你的业务场景中需要用到异步任务,就可以考虑使用celery. 使用 ...
- python celery任务分发
<div id="cnblogs_post_body" class="blogpost-body"><p>Celery是由Python开 ...
- python celery 多work多队列
1.Celery模块调用 既然celery是一个分布式的任务调度模块,那么celery是如何和分布式挂钩呢,celery可以支持多台不通的计算机执行不同的任务或者相同的任务. 如果要说celery的分 ...
- Python—Celery 框架使用
一.Celery 核心模块 1. Brokers brokers 中文意思为中间人,在这里就是指任务队列本身,接收生产者发来的消息即Task,将任务存入队列.任务的消费者是Worker,Brokers ...
- python celery 异步学习
1.运行redis 2.安装celery:pip install celery[redis] 3.vim task.py import time from celery import Celery b ...
- python celery 时区&结果(性能)的坑
本文主要介绍最近使用celery遇到的两个坑.关于时区,以及是否保留结果(celery使用rabbitmq). 先说结论:定时任务记得配置时区:丢弃结果对使用rabbitmq对celery来说,性能提 ...
- python celery rabbitmq--- pypi image from ustc
https://lug.ustc.edu.cn/wiki/mirrors/help/pypi 那么为啥要用celery ?(http://xiaorui.cc/2014/11/16/celery-ra ...
随机推荐
- wordpress 主题安装 您点击的链接已过期 nginx 出现413 Request Entity Too Large
1 nginx 出现413 Request Entity Too Large 问题是限制上传大小,解决: 1.打开nginx配置文件 nginx.conf, 路径一般是:/etc/nginx/ngin ...
- (20002, b'DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (127.0.0.1:3306)\n')
使用python 3.7 pymssql 连接本地mysql 5.6 报错 解决:参考 https://www.cnblogs.com/springbrotherhpu/p/11503139.html ...
- Install pyaudio on Ubuntu
pip install python3-pyaudio sudo apt-get install portaudio19-dev python-all-dev pip install pyaudio
- v-for & for...in vs for...of
v-for & for...in vs for...of for..in vs for...of for (const key in object) { if (Object.hasOwnPr ...
- React Hooks: useRef All In One
React Hooks: useRef All In One useRef https://reactjs.org/docs/hooks-reference.html#useref refs xgqf ...
- 海 鱼立 鲷 & 海䲞鲷
海 鱼立 鲷 & 海䲞鲷 䲞 lì 鲷 diāo 二长棘鲷 二长棘鲷(学名:Parargyrops edita)为辐鳍鱼纲鲈形目鲷科二长棘鲷属的鱼类,俗名板鱼.䲞鱼.盘仔鱼.立花.赤鬃.长鳍. ...
- Python Web Frameworks
Python Web Frameworks top 10 Python web frameworks Django (Full-stack framework) Flask (Micro framew ...
- js & array remove one item ways
js & array remove one item ways // array remove one item ways let keys = [1,2,3,4,5,6,7]; let ke ...
- EventEmitter & custom events & sub/pub
EventEmitter & custom events & sub/pub https://repl.it/@xgqfrms/PPLabs-frontend-answers // 5 ...
- vue $emit bug
vue $emit bug https://www.cnblogs.com/xgqfrms/p/11146189.html solution https://forum.vuejs.org/t/emi ...