celery

celery trying shutdown worker by raising SystemExit in task_postrun signal but always hangs and the main process never exits

拟墨画扇 提交于 2019-12-05 00:30:40
问题 I'm trying to shutdown the main celery process by raisin SystemExit() in the task_postrun signal. The signal gets fired just fine, and the exception gets raised, but the worker never completely exits and just hangs there. HOW DO I MAKE THIS WORK? Am I forgetting some setting somewhere? Below is the code that I'm using for the worker (worker.py): from celery import Celery from celery import signals app = Celery('tasks', set_as_current = True, broker='amqp://guest@localhost//', backend="mongodb

Run while loop concurrently with Flask server

跟風遠走 提交于 2019-12-05 00:30:37
问题 I'm updating some LEDs using python. I've been doing this like so: from LEDs import * myLEDs = LEDs() done = False while not done: myLEDs.iterate() I wanted to use Flask to act as a bridge between some nice-looking ReactJS front-end I can run in my browser (to change the current pattern, etc) and the LED-controlling code in Python. I have Flask working fine, can handle HTTP requests, etc. I'm wondering how I can set myLEDs.iterate() to continuously run (or run on a rapid schedule)

Correct setup of django redis celery and celery beats

ⅰ亾dé卋堺 提交于 2019-12-05 00:09:41
I have being trying to setup django + celery + redis + celery_beats but it is giving me trouble. The documentation is quite straightforward, but when I run the django server, redis, celery and celery beats, nothing gets printed or logged (all my test task does its log something). This is my folder structure: - aenima - aenima - __init__.py - celery.py - criptoball - tasks.py celery.py looks like this: from __future__ import absolute_import, unicode_literals import os from django.conf import settings from celery import Celery # set the default Django settings module for the 'celery' program. os

前端,DJ

独自空忆成欢 提交于 2019-12-05 00:08:10
Vue模块 1、Vue都有哪些指令,简单说说? """ Vue里面常见指令有文本指令:v-text、v-html,属性指令:v-bind,方法指令:v-on,条件指令:v-if、v-show,循环指令:v-for v-html在v-text基础上,还可以解析html代码 v-show是以display:none方式来渲染隐藏的标签,v-if会真的隐藏标签不渲染 """ 2、简单聊一聊Vue组件化开发 """ Vue中的每一个组件就是一个vue实例,也就是vue对象。 组件是由html、css、js组成的独立的页面结构单位,可以完成页面结构的代码复用 一般我们先定义一个组件,然后在使用的父组件中注册,最后使用定义的组件 定义组件template里写html,style中写样式,script中写逻辑 """ 3、vue中你用过哪些第三方插件 """ vue中最常用的插件有 管理路由的vue-router,管理组件间数据仓库的vuex 还使用了vue-cookies来管理cookie,axios来完成前后台的ajax交互 """ drf模块 1、什么是web接口,restful接口规范 """ web接口有四个特点:规定前后台的交互方式;请求的链接;请求的参数;响应的数据结果 restful接口规范可以分三块来讲:请求链接,请求方式,响应结果 请求链接,采用https协议,带api字眼

How to store the result of a delay-call using celery in a django view?

和自甴很熟 提交于 2019-12-04 23:06:50
问题 I`ve followed the guidelines in http://celeryq.org/docs/django-celery/getting-started/first-steps-with-django.html and created a view that calls my test method in tasks.py: import time from celery.decorators import task @task() def add(x, y): time.sleep(10) return x + y But if my add-method takes a long time to respond, how can I store the result-object I got when calling add.delay(1,2) and use it to check the progress/success/result using get later? 回答1: You only need the task-id: result =

Read Celery configuration from Python properties file

放肆的年华 提交于 2019-12-04 21:01:29
问题 I have an application that needs to initialize Celery and other things (e.g. database). I would like to have a .ini file that would contain the applications configuration. This should be passed to the application at runtime. development.init: [celery] broker=amqp://localhost/ backend=amqp://localhost/ task.result.expires=3600 [database] # database config # ... celeryconfig.py: from celery import Celery import ConfigParser config = ConfigParser.RawConfigParser() config.read(...) # Pass this

Where is the data provided by django-celery urls stored? How long is the data available? And what is the memory consumption?

萝らか妹 提交于 2019-12-04 19:57:52
I am starting a project using django celery and I am making ajax calls to the task urls provided by 'djcelery.urls'. I would like to know a few things about this data: Where is that information being stored? Is it called from the djcelery tables in my django projects database or is it kept on the RabbitMQ server? My understanding of the djcelery tables in my database is that they are only for monitoring the usage using the camera. If it is being stored on the RabbitMQ server, how long will the tasks status report be available? How much memory does this data consume? Do I need to flush the task

Django - How to use asynchronous task queue with celery and redis

…衆ロ難τιáo~ 提交于 2019-12-04 19:56:54
#In my views.py file pi1 = None pis1 = None def my_func(): #Essentially this function sets a random integer to pi1 and pis1 global pi1, pis1 pi1 = randint(0,9) pis1 = randint(0,9) return def index(request): my_func() context = { "pi1" : pi1, "pis1" : pis1, } return render(request, "index.html", context) #In the index.html file <h1>{{ pi1 }}</h1> <h1>{{ pis1 }}</h1> I've removed a lot of my code for simplicity, but this is the gist of it. Despite the code that I've posted for my_func, it is a time consuming function that causes index.html to load for awhile when it is accessed. How would I run

How can I view the enqueued tasks in RabbitMQ?

左心房为你撑大大i 提交于 2019-12-04 19:39:49
问题 I'm using RabbitMQ as my message broker and my workers are Celery tasks. I'm trying to diagnose an issue where I'm enqueue tasks to RabbitMQ but Celery doesn't pick then up. Is there a way I can check what tasks are enqueued in RabbitMQ? I'd like to see the date and time when they are enqueued, any ETA is specified, the arguments and the task name. I haven't been able to find this information in the docs — maybe I've overlooked it — and was hoping that some of you might know an easy way to

I'm getting an “ERROR (spawn error)” when I try to start my celery/supervisor instance

不问归期 提交于 2019-12-04 19:28:55
I've gone through how to use celery on my django production server using supervisor . However when I try to start supervisor with sudo supervisorctl start app-celery - it returns: app-celery: ERROR (spawn error) Here is my config /etc/supervisor/conf.d/app-celery.conf : [program:app-celery] command=/home/zorgan/app/env/bin/celery worker -A draft1 --loglevel=INFO directory=/home/zorgan/app/draft1 numprocs=1 stdout_logfile=/var/log/supervisor/celery.log stderr_logfile=/var/log/supervisor/celery.log autostart=true autorestart=true startsecs=10 ; Need to wait for currently executing tasks to