安装: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. AF_INET与套接字SOCKET

    一.SOCKET--套接字 套接字最初是为同一主机上的应用程序所创建,使得主机上运行的一个程序(又名一个进程)与另一个运行的程序进行通信.这就是所谓的进程间通信(Inter Process Commu ...

  2. codeforce 855B

    B. Marvolo Gaunt's Ring time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  3. exgcd&&中国剩余定理专题练习

    hdu1573求中国剩余定理解的个数 #include <iostream> #include <cstdio> using namespace std; int a[100] ...

  4. JavaScript & Atomics

    JavaScript & Atomics Atomics 对象提供了一组静态方法对 SharedArrayBuffer 和 ArrayBuffer 对象进行原子操作. Atomics.add ...

  5. Ethical Hacking Tutorials

    Ethical Hacking Tutorials Free Ethical Hacking Tutorials https://www.guru99.com/ethical-hacking-tuto ...

  6. GitHub Actions

    GitHub Actions CI/CD & testing https://github.com/features/actions refs xgqfrms 2012-2020 www.cn ...

  7. vue 使用stylus

    λ yarn add stylus stylus-loader --dev <style scoped lang="stylus"> div color #ff4488 ...

  8. Flutter: 判断是Android还是Ios

    /// 在ui中使用下面的这个判断 Theme.of(context).platform == TargetPlatform.android /// 而不是 import 'dart:io' Plat ...

  9. PAUL ADAMS ARCHITECT :阿联酋和美国富人推动英国高端房地产市场

    来自2020年前三季度的数据显示,在英国高端市场上,由国际买家担保的抵押贷款交易数量最多,阿联酋目前处于领先地位.到目前为止,在2020年完成的所有交易中,有35%来自阿联酋. PAUL ADAMS ...

  10. .Net Core 3.1浏览器后端服务(三) Swagger引入与应用

    一.前言 前后端分离的软件开发方式已逐步成为互联网项目开发的业界标准,前后端分离带来了诸多好处的同时,也带来了一些弊端. 接口文档的维护就是其中之一,起初前后端约定文档规范,开发的很愉快,随着时间推移 ...