惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point Blog
Hacker News: Ask HN
Hacker News: Ask HN
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
WordPress大学
WordPress大学
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
N
Netflix TechBlog - Medium
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 聂微东
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 叶小钗
Cisco Talos Blog
Cisco Talos Blog
S
Schneier on Security
T
Threat Research - Cisco Blogs
腾讯CDC
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Hacker News
The Hacker News
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
GbyAI
GbyAI
N
News | PayPal Newsroom
L
LINUX DO - 最新话题
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Palo Alto Networks Blog
T
Tenable Blog
S
Secure Thoughts
T
Threatpost
V2EX - 技术
V2EX - 技术
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Vercel News
Vercel News
罗磊的独立博客
P
Privacy & Cybersecurity Law Blog
Engineering at Meta
Engineering at Meta
小众软件
小众软件
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
Y
Y Combinator Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
P
Privacy International News Feed
H
Heimdal Security Blog
量子位
B
Blog

Mox的笔记库

2026PPoPP MLIR Tutorial学习 | Mox的笔记库 MacOS配置《明日方舟:终末地》 | Mox的笔记库 2025:向内生长 | Mox的笔记库 由mlir::ExecutionEngine引发的跨系统问题 | Mox的笔记库 WSL2配置Cuda-Tile环境记录(未完待续) | Mox的笔记库 Vibe Coding手搓项目记录 | Mox的笔记库 给Debian上包——以DuckDB为例 | Mox的笔记库 UCPD.sys事件存档 | Mox的笔记库 换新电脑之Mac mini M4从购买到配置 | Mox的笔记库 Mac配置MLX-C开发环境 | Mox的笔记库 RISC-V meets RDBMS——RISC-V架构上可运行数据库一览 | Mox的笔记库 DuckDB Sort实现调查 | Mox的笔记库 修复Redis在树莓派5上无法运行的问题 | Mox的笔记库 如何在MLIR中自定义类型并且输出运行 | Mox的笔记库 网站网络结构变更记录 | Mox的笔记库 EDBT25论文阅读:PhoebeDB——A Disk-Based RDBMS Kernel for High-Performance and Cost-Effective OLTP SIGMOD25论文阅读:BPF-DB:——A Kernel-Embedded Transactional Database Management System For eBPF Applications Apache Arrow Gandiva项目解析 | Mox的笔记库 VLDB24论文阅读:Cloud-Native Database Systems and Unikernels——Reimagining OS Abstractions for Modern Hardware NoisePage源码分析(未完待续) | Mox的笔记库 VLDB20论文阅读:Mainlining Databases——Supporting Fast Transactional Workloads on Universal Columnar Data File Formats VLDB17论文阅读:Relaxed Operator Fusion for In-Memory Databases:Making Compilation, Vectorization, and Prefetching Work Together At Last 论文阅读:How not to structure your database-backed web applications——a study of performance bugs in the wild SIGMOD24阅读:ROME——Robust Query Optimization via Parallel Multi-Plan Execution 文章阅读:First Past the Post-Evaluating Query Optimization in MongoDB SIGMOD文章阅读:Apache Calcite——A Foundational Framework for Optimized Query Processing Over Heterogeneous Data Sources VLDB23论文阅读:Analyzing the Impact of Cardinality Estimation on Execution Plans in Microsoft SQL Server SIGMOD22论文阅读:Efficient Massively Parallel Join Optimization for Large Queries VLDB论文阅读:Weaving Relations for Cache Performance VLDB22论文阅读:ConnectorX——Accelerating Data Loading From Databases to Dataframes 论文阅读:UniKraft-Fast, Specialized Unikernels the Easy Way 当DuckDB遇上RISC-V | Mox的笔记库 SIGMOD25论文阅读:An Elephant Under The Microscope——Analyzing The Interaction Of Optimizer Components In PostgreSQL 论文阅读:Compile-Time Analysis of Compiler Frameworks for Query Compilation VLDB23阅读:Bringing Compiling Databases to RISC Architectures SIGMOD24文章阅读:Query Compilation Without Regrets | Mox的笔记库 淦!MLIR输出Hello World不应该这么难! | Mox的笔记库 2024:拥挤年代的想象与创造 | Mox的笔记库 如何给自己的博客添加MLIR和LLVM IR语法高亮 | Mox的笔记库 博客重构:从Hexo到Astro | Mox的笔记库 VLDB19-Parsing Gigabytes of JSON per Second论文阅读 CIDR25:Runtime-Extensible Parsers阅读 | Mox的笔记库 SIGMOD24文章阅读:VeriTxn | Mox的笔记库 MLIR学习资料整理 | Mox的笔记库 VLDB23文章阅读——Exploiting Cloud Object Storage for High-Performance Analytics VLDB24——OLAP on Modern Chiplet-Based Processors走马观花阅读 如何让数据库中的Python跑的更快-VLDB22-YeSQL文章阅读 | Mox的笔记库 你好,世界! | Mox的笔记库 如何愉快的运行一个MLIR程序 | Mox的笔记库 让系统研究更有意义:HarmonyOS NEXT的教训和经验——讲座回顾 | Mox的笔记库 VLDB22:YeSQL文章阅读(已废弃) | Mox的笔记库 UNSW 24T3 COMP9336上课记录 | Mox的笔记库 Velox开发环境配置踩坑记录 | Mox的笔记库 LingoDB源码编译与分析 | Mox的笔记库 论文阅读:Declarative Sub-Operators for Universal Data Processing 论文阅读:Designing an Open Framework for Query Optimization and Compilation MLIR Toy Tutorial实践记录 | Mox的笔记库 2024年7月RSSHub开发体验 | Mox的笔记库 LLVM-Kaleidoscope实操踩坑记录 | Mox的笔记库 澳洲大学计算机硕士比较 | Mox的笔记库 论文阅读——CDUL:CLIP-Driven Unsupervised Learning for Multi-Label Image Classification CVPR2023-CLIP算法调研 | Mox的笔记库 论批量快速添加图片与视频水印的事 | Mox的笔记库 基于元信息写入的服务器压力测试 | Mox的笔记库 家庭组网IPv6+Mesh折腾 | Mox的笔记库 MjAyMw==,希望,前进与平庸之道 | Mox的笔记库 code-server初体验 | Mox的笔记库 从Nginx到Caddy | Mox的笔记库 RMM观察与初探 | Mox的笔记库 计算机网络课设——UDP/TCP/TLS Socket实验 | Mox的笔记库 JQuery的XSS初探 | Mox的笔记库 生产实习记录 | Mox的笔记库 Fedora-CoreOS配置与试用(2023年) | Mox的笔记库 Electron学习笔记 | Mox的笔记库 ServerSentEvent学习 | Mox的笔记库 报告翻译:容器云的安全挑战 | Mox的笔记库 Vagrant配置Metarget靶场环境 | Mox的笔记库 OpenAI-whisper折腾 | Mox的笔记库 202202,困惑,混乱与未曾设想之路 | Mox的笔记库 2022年Hack the box:Tier1免费区全解 | Mox的笔记库 Navidrome部署记录 | Mox的笔记库 长安杯2021-snake复现 | Mox的笔记库 报告概要翻译:OBFUSCATING C++ PROGRAMS VIA CONTROL FLOW FLATTENING 从零开始的Django CVE-2022-28346复现 | Mox的笔记库 2022CISCN(西北区赛)-The shinning | Mox的笔记库 Docker+QEMU+Arm64(Ubuntu)+环境配置(2022版) | Mox的笔记库 Arch Linux运行树莓派系统(2022年) | Mox的笔记库 2022CISCN初赛-ez_usb-复盘WriteUp | Mox的笔记库 Arch Linux迁移计划 | Mox的笔记库 Django事务使用 | Mox的笔记库 记录第一次EduSRC上报 | Mox的笔记库 Jetbrain问题应急处理 | Mox的笔记库 Waline部署记录 | Mox的笔记库 Frida hook初次实战 | Mox的笔记库 NodeMCU-MicroPython配置实录 | Mox的笔记库 Log4j2漏洞复现 | Mox的笔记库 2022长安“战疫”网络安全卫士守护赛回顾 | Mox的笔记库 2021年12月 Vivo千镜杯回顾 | Mox的笔记库 Windows的WSL2+Docker初探 | Mox的笔记库 Hexo部署安装全流程回顾 | Mox的笔记库
Celery5.2学习&配置 | Mox的笔记库
MocusEZ · 2022-04-19 · via Mox的笔记库

手头的Django 3.2项目需要Celery,一翻百度,发现全是基于Django 2.2的帖子,再一看官方仓库和文档,妈耶,清一色英文说明。有个半吊子的中文翻译(又不是不能看.jpg),只能自己摸坑慢慢爬去了。

本篇文章全程无图,字多慎入

官方仓库地址:

https://github.com/celery/celery/

官方文档

https://docs.celeryq.dev/en/stable/

自己写的项目(后端不会长期开着,要测试本地自行踩坑自建)

https://gitee.com/mocus/todo-list

同一批写的项目,如果ta们开放权限的话应该能看到,也是用了celery的

https://gitee.com/li-jiayin167

https://gitee.com/BabyMuu/todo-api

https://github.com/YichenWu11/simple-todolist

什么是Celery

高性能异步框架,支持异步调用,需要RabbitMQ或redis作为队列支撑

我觉得这个讲的不错,这里就不过多赘述了,里面也提供了上手样例

高性能异步框架Celery入坑指南

实在不行,还可以跟着官方得初步教程走

First Steps with Celery

安装命令

pip install -U "celery[redis]"

踩坑

Task handler raised error: ValueError(‘not enough values to unpack (expected 3, got 0)’)

pip install eventlet # celery 4.0+版本以后不支持在windows运行,还需额外安装eventlet库

celery 报错 in on_task_received 解决

专门有一个刷新的坑,celery队列不能共用(比如本地调试用了redis的db1和db2,上传到服务器上的时候,服务器上还是db1和db2,这时候本地再用db1和db2就会发生一些奇怪事情,所以本地最好用db3和db4)

简单上手

Tip:“简单上手”是早些时间的笔记,要想用在Django还需要额外的配置

连接控制台

celery -A tasks worker --loglevel=info

celery -A task worker --loglevel=info -P eventlet

celery -A tasks control rate_limit tasks.add 10/m

任务文件

from celery import Celery

app = Celery('tasks', broker='pyamqp://guest:guest@14.222.31.232//')

@app.tasks

def add(x, y):

print("input is {} {}".format(x,y))

return x + y

if __name__ == '__main__':

print('task start....')

result = add.delay(2,3)

print('task end....')

print(result)

开启任务

from task import add

add.delay(3,4)

print(result.ready())

获取运行结果

判断

result.get(timeout=1)

获取运行结果

需要设置backend

当时第一次用的是RabbitMQ,不像redis一样可以做backend,所以就没有下文了

连接redis

在settings.py里面配置

redis://:password@hostname:port/db_number

Django 3.2联动Celery5.2

如果没按上面的指令安装,下面这个也能实现同样效果

pip install celery

pip install redis

给Django配置计划任务需要的插件

pip install django-celery-beat

插件的官方说明书

Periodic Tasks

基本按照下面这个连接的方案配置,这个方案讲述过于简略,在后期配置埋了坑

django 使用 celery

结合下面这个教程才解决问题

Django项目使用Celery

单独在settings.py配置关键字CELERY_BEAT_SCHEDULER

CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler'

别问我为什么不是其他关键字,反正其他的都没成功,还没找到原因

动态添加&修改任务

Django使用 django-celery-beat动态添加定时任务

从设置上设定初始任务

是这样写,但没成功过

CELERYBEAT_SCHEDULE = {

# 每过10秒执行以下task1.add的定时任务

'task1':{

'task': 'course-task',

'schedule': timedelta(seconds=10),

'options':{

'queue': 'beat_tasks'

}

},

}

配置后台运行

启动处理

celery multi start w1 -A proj -l info

有计划任务的还需要单独加一条下面的(配置好CELERY_BEAT_SCHEDULER的情况下)

celery multi start w1 -A proj beat -l info

如果没配置好,就用下面这条

celery -A todo beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler

最正规的方式应该是配合supervisor,但是不太会

找到一篇上古文章讲multi实现的

celery源码分析:multi命令分析

Tip:最后beat其实是失效的,演示之前手动进入容器打开了定时刷新,最后

答辩也没有用上就是了

替代品

搜资料的时候发现了这个东西,号称要取代Celery,没时间评测,但貌似有中文文档

https://github.com/ydf0509/funboost

结语

时间太紧,英文文档没好好看,最后任务也就凑合着能用,也谈不上精通。做个记录,以后遇到新的坑也能溯源。

后续

2022.4.27

用能力的自己爬出去看

看来真的是天下苦Celery久矣

不得不吐槽一下 Python 的任务队列,异步支持太差了