跳转到主要内容
此内容尚未提供您的语言版本,正在以英文显示。

Celery

技能 已验证 活跃

Distributed task queue system for Python enabling asynchronous execution of background jobs, scheduled tasks, and workflows across multiple workers with Django, Flask, and FastAPI integration.

目的

To serve as a definitive guide for implementing and managing distributed task queues in Python applications using Celery.

功能

  • Distributed task execution and scheduling
  • Asynchronous background job processing
  • Complex task workflows and orchestration
  • Robust error handling with retries and backoff
  • Integration with Python web frameworks (Django, Flask, FastAPI)

使用场景

  • Offloading long-running operations like email sending or report generation
  • Implementing scheduled tasks similar to cron jobs
  • Distributing computation across multiple worker nodes
  • Building complex asynchronous workflows with task dependencies

非目标

  • Replacing simple asyncio for in-process async I/O
  • Providing real-time request/response handling
  • Serving as a solution for minimal infrastructure needs

工作流

  1. Install Celery and necessary dependencies.
  2. Configure the Celery application, including broker and backend.
  3. Define tasks using decorators or Task classes.
  4. Execute tasks asynchronously using `.delay()` or `.apply_async()`.
  5. Monitor task execution via workers, Flower, or inspection commands.
  6. Implement advanced features like periodic tasks, workflows, and error handling.

实践

  • Task design
  • Error handling
  • Performance optimization
  • Monitoring
  • Security

先决条件

  • Python environment
  • Celery package (`pip install celery`)
  • A message broker (e.g., Redis, RabbitMQ)
  • An optional result backend (e.g., Redis, database)

安装

npx skills add bobmatnyc/claude-mpm-skills

通过 npx 运行 Vercel skills CLI(skills.sh)— 需要本地安装 Node.js,以及至少一个兼容 skills 的智能体(Claude Code、Cursor、Codex 等)。前提是仓库遵循 agentskills.io 格式。

质量评分

已验证
98 /100
1 day ago 分析

信任信号

最近提交29 days ago
星标44
许可证MIT
状态
查看源代码