celery

Python, Celery, Flask, “working outside of application context”

三世轮回 提交于 2020-01-30 13:04:28
问题 I am trying to schedule tasks using Celery and Python for a Flask app. I basically want to run a function in another directory every x amount of time and make it a celery task. I import the function test_check and I try and put it under a celery task called testcheck(), however, I get the error: working outside of application context How can I fix this? Here is my setup: from app import app from celery import Celery from datetime import timedelta from app.mod_check.views import test_check

Python, Celery, Flask, “working outside of application context”

我怕爱的太早我们不能终老 提交于 2020-01-30 13:04:12
问题 I am trying to schedule tasks using Celery and Python for a Flask app. I basically want to run a function in another directory every x amount of time and make it a celery task. I import the function test_check and I try and put it under a celery task called testcheck(), however, I get the error: working outside of application context How can I fix this? Here is my setup: from app import app from celery import Celery from datetime import timedelta from app.mod_check.views import test_check

异步队列---celery的使用

守給你的承諾、 提交于 2020-01-30 07:03:33
先来看一份伪代码和生产者消费者模式 生产者---消费者模式 首先安装celery 再看看大体步骤 下面在自己具体实现一次 Linux下启动Celery服务: celery -A celery文件夹下的main文件 worker -l info Windows下启动celery服务: celery -A 自己定义的celery任务的main文件 worker -l info -P eventlet 如果是在Windows下, 需要再安装一个包 叫: eventlet pip install eventlet 启动命令后面要加 -P eventlet 否则会报错 自己实现 1首先定义一个celery包 包里面是这样: 注意: 任务包里的任务文件只能叫tasks.py, 这是固定的, 不能起别的名字!!! 任务包里的任务文件只能叫tasks.py, 这是固定的, 不能起别的名字!!! 任务包里的任务文件只能叫tasks.py, 这是固定的, 不能起别的名字!!! 重要事情说三遍 再来看每一个文件夹里的内容 首先看main文件: 再来看config配置文件 最后看任务包中的tasks文件 最后启动celery, 之后在调用就可以了 在terminal启动命令: celery -A 自己定义的celery任务的main文件 worker -l info -P eventlet

tornado异步请求非阻塞

∥☆過路亽.° 提交于 2020-01-30 00:22:32
前言也许有同学很迷惑:tornado不是标榜异步非阻塞解决10K问题的嘛?但是我却发现不是torando不好,而是你用错了 比如最近发现一个事情:某网 前言 也许有同学很迷惑:tornado不是标榜异步非阻塞解决10K问题的嘛?但是我却发现不是torando不好,而是你用错了.比如最近发现一个事情:某网站打开页面很慢,服务器cpu/内存都正常.网络状态也良好. 后来发现,打开页面会有很多请求后端数据库的访问,有一个mongodb的数据库业务api的rest服务.但是它的tornado却用错了,一步步的来研究问题: 说明 以下的例子都有2个url,一个是耗时的请求,一个是可以或者说需要立刻返回的请求,我想就算一个对技术不熟,从道理上来说的用户, 他希望的是他访问的请求不会影响也不会被其他人的请求影响 #!/bin/env python import tornado.httpserver import tornado.ioloop import tornado.options import tornado.web import tornado.httpclient import time from tornado.options import define, options define("port", default=8000, help="run on the given port

Run multiple Celery tasks using a topic exchange

ⅰ亾dé卋堺 提交于 2020-01-29 09:44:28
问题 I'm replacing some homegrown code with Celery, but having a hard time replicating the current behaviour. My desired behaviour is as follows: When creating a new user, a message should be published to the tasks exchange with the user.created routing key. Two Celery tasks should be trigged by this message, namely send_user_activate_email and check_spam . I tried implementing this by defining a user_created task with a ignore_result=True argument, plus a task for send_user_activate_email and

Celery

大城市里の小女人 提交于 2020-01-27 20:34:56
Celery 一 、什么是Clelery Celery是一个简单、灵活且可靠的,处理大量消息的分布式系统专注于实时处理的异步任务队列 同时也支持任务调度 1. Celery架构 Celery 的架构由三部分组成,消息中间件(message broker),任务执行单元(worker)和任务执行结果存储(task result store)组成。 1.2 消息中间件 Celery 本身不提供消息服务,但是可以方便的和第三方提供的消息中间件集成。包括, RabbitMQ , Redis 等等 1.3 任务执行单元 Worker 是 Celery 提供的任务执行的单元, worker 并发的运行在分布式的系统节点中。 1.4 任务结果存储 Task result store 用来存储 Worker 执行的任务的结果, Celery 支持以不同方式存储任务的结果,包括 AMQP , redis 等 1.5版本支持情况 Celery version 4.0 runs on Python ❨2.7, 3.4, 3.5❩ PyPy ❨5.4, 5.5❩ This is the last version to support Python 2.7, and from the next version (Celery 5.x) Python 3.5 or newer is required. If

celery使用

一曲冷凌霜 提交于 2020-01-27 04:39:10
Celery 1.什么是Clelery Celery是一个简单、灵活且可靠的,处理大量消息的分布式系统 专注于实时处理的异步任务队列 同时也支持任务调度 Celery架构 Celery的架构由三部分组成,消息中间件(message broker),任务执行单元(worker)和任务执行结果存储(task result store)组成。 消息中间件 Celery本身不提供消息服务,但是可以方便的和第三方提供的消息中间件集成。包括,RabbitMQ, Redis等等 任务执行单元 Worker是Celery提供的任务执行的单元,worker并发的运行在分布式的系统节点中。 任务结果存储 Task result store用来存储Worker执行的任务的结果,Celery支持以不同方式存储任务的结果,包括AMQP, redis等 版本支持情况 Celery version 4.0 runs on Python ❨2.7, 3.4, 3.5❩ PyPy ❨5.4, 5.5❩ This is the last version to support Python 2.7, and from the next version (Celery 5.x) Python 3.5 or newer is required. If you’re running an older version of

Celery

吃可爱长大的小学妹 提交于 2020-01-26 08:13:15
什么是Clelery Celery是一个简单、灵活且可靠的,处理大量消息的分布式系统 专注于实时处理的异步任务队列 同时也支持任务调度 celery能做什么 异步任务 定时任务 Celery架构 Celery的架构由三部分组成,消息中间件(message broker),任务执行单元(worker)和任务执行结果存储(task result store)组成 消息中间件 Celery本身不提供消息服务,但是可以方便的和第三方提供的消息中间件集成。包括,RabbitMQ, Redis等等 任务执行单元 Worker是Celery提供的任务执行的单元,worker并发的运行在分布式的系统节点中。 任务结果存储 Task result store用来存储Worker执行的任务的结果,Celery支持以不同方式存储任务的结果,包括AMQP, redis等 版本支持情况 Celery version 4.0 runs on Python ❨2.7, 3.4, 3.5❩ PyPy ❨5.4, 5.5❩ This is the last version to support Python 2.7, and from the next version (Celery 5.x) Python 3.5 or newer is required. If you’re running an older

django websocket return number in loop as same as other recieves

痞子三分冷 提交于 2020-01-25 10:13:17
问题 hi guys i really need your help here ! i want create something that send a number from 0 to 100 in python django and all of users that connected to websocket recieves them for example user one opens the page and he gets 0 , 1 , 2 .. and then user two connects to websocket but he dont get them from 0 and he see what user one see's! for example if user one is on number 10 user two start from number 10 as exact user one see's and after both of users or if 10000 user connected finished the loop

Celery完成定时任务

感情迁移 提交于 2020-01-25 05:12:10
1.什么是Celery Celery是一个简单、灵活且可靠的,处理大量消息的分布式系统 专注于实时处理的异步任务队列 同时也支持任务调度 celery支持linux,如果windows使用celery出了问题不解决 Celery架构 Celery的架构由三部分组成,消息中间件(message broker),任务执行单元(worker)和任务执行结果存储(task result store)组成。 消息中间件 Celery本身不提供消息服务,但是可以方便的和第三方提供的消息中间件集成。包括,RabbitMQ, Redis等等 任务执行单元 Worker是Celery提供的任务执行的单元,worker并发的运行在分布式的系统节点中。 任务结果存储 Task result store用来存储Worker执行的任务的结果,Celery支持以不同方式存储任务的结果,包括AMQP, redis等 版本支持情况 Celery version 4.0 runs on Python ❨2.7, 3.4, 3.5❩ PyPy ❨5.4, 5.5❩ This is the last version to support Python 2.7, and from the next version (Celery 5.x) Python 3.5 or newer is required. If you