安装: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的使用的更多相关文章

  1. python celery + redis

    redis http://debugo.com/python-redis celery http://docs.jinkan.org/docs/celery/getting-started/intro ...

  2. python celery多worker、多队列、定时任务

    python celery多worker.多队列.定时任务  

  3. python—Celery异步分布式

    python—Celery异步分布式 Celery  是一个python开发的异步分布式任务调度模块,是一个消息传输的中间件,可以理解为一个邮箱,每当应用程序调用celery的异步任务时,会向brok ...

  4. Python Celery队列

    Celery队列简介: Celery 是一个 基于python开发的分布式异步消息任务队列,通过它可以轻松的实现任务的异步处理, 如果你的业务场景中需要用到异步任务,就可以考虑使用celery. 使用 ...

  5. python celery任务分发

    <div id="cnblogs_post_body" class="blogpost-body"><p>Celery是由Python开 ...

  6. python celery 多work多队列

    1.Celery模块调用 既然celery是一个分布式的任务调度模块,那么celery是如何和分布式挂钩呢,celery可以支持多台不通的计算机执行不同的任务或者相同的任务. 如果要说celery的分 ...

  7. Python—Celery 框架使用

    一.Celery 核心模块 1. Brokers brokers 中文意思为中间人,在这里就是指任务队列本身,接收生产者发来的消息即Task,将任务存入队列.任务的消费者是Worker,Brokers ...

  8. python celery 异步学习

    1.运行redis 2.安装celery:pip install celery[redis] 3.vim task.py import time from celery import Celery b ...

  9. python celery 时区&结果(性能)的坑

    本文主要介绍最近使用celery遇到的两个坑.关于时区,以及是否保留结果(celery使用rabbitmq). 先说结论:定时任务记得配置时区:丢弃结果对使用rabbitmq对celery来说,性能提 ...

  10. 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 ...

随机推荐

  1. Leetcode(5)-最长回文子串(包含动态规划以及Manacher算法)

    给定一个字符串 s,找到 s 中最长的回文子串.你可以假设 s 的最大长度为1000. 示例 1: 输入: "babad" 输出: "bab" 注意: &quo ...

  2. C++ 结构体 segment fault

    形如 struct node { int key; int height; int size; //tree node 个数 node *left, *right; node(int x) : key ...

  3. pycharm 与 anaconda 关联

    anaconda Anaconda指的是一个开源的Python发行版本,集成了许多数据分析的库. 使用tersorflow进行机器学习时常用Anaconda pycharm PyCharm是一种Pyt ...

  4. HihoCoder1445 后缀自动机二·重复旋律5(后缀自动机 子串种数)

    题意: 询问串的不同子串个数 思路: 后缀自动机每个节点表示以当前字符结尾的一系列后缀,个数为\(maxlen - minlen\),其中\(minlen = maxlen[father]\). 代码 ...

  5. Spring配置声明式事务

    Spring的事务有两种配置,一种是编程式,另一种是声明式,这里我们配置的是声明式事务 <?xml version="1.0" encoding="UTF-8&qu ...

  6. Vue UI lib missing vue bug

    Vue UI lib missing vue bug Error Uncaught TypeError: Cannot read property 'prototype' of undefined a ...

  7. 字节跳动-前端面试题 Multi Promise Order

    字节跳动-前端面试题 Multi Promise Order Promise Order Async/Await async function async1 () { console.log('asy ...

  8. Web API & Element & DOM

    Web API & Element & DOM Element https://developer.mozilla.org/en-US/docs/Web/API/Element HTM ...

  9. go-admin在线开发平台学习-1[安装、配置、启动]

    项目介绍 go-admin 是一个中后台管理系统,基于(gin, gorm, Casbin, Vue, Element UI)实现.主要目的是为了让开发者更专注业务,减少重复代码的编写,节省时间,提升 ...

  10. Python学习相关链接

    感觉挺全的: http://www.cnblogs.com/xinshiye/p/9015187.html 也挺全的:http://www.cnblogs.com/toutou/category/72 ...