wshobson avatar

Python Background Jobs

Solid foundation for implementing async task processing in Python apps. Covers the essential patterns you'll actually need: job state management with proper status tracking, idempotent task design to handle retries safely, and Celery configuration with realistic timeout and retry settings. The code examples show practical implementations for common scenarios like payment processing, data exports, and webhook handling. Includes dead letter queue patterns for handling permanent failures and proper API design for job polling. Won't make you an expert in every queue system, but gives you working patterns that translate well across Redis, RQ, or cloud-native solutions.

skills.sh installs
11.6K
GitHub stars
42.4K
last updated
Aug 21, 2026

Install

$ npx -y skills add wshobson/agents --skill python-background-jobs --agent claude-code

Installs into .claude/skills of the current project.

Files

Python Background Jobs & Task Queues

Decouple long-running or unreliable work from request/response cycles. Return immediately to the user while background workers handle the heavy lifting asynchronously.

When to Use This Skill

  • Processing tasks that take longer than a few seconds
  • Sending emails, notifications, or webhooks
  • Generating reports or exporting data
  • Processing uploads or media transformations
  • Integrating with unreliable external services
  • Building event-driven architectures

Core Concepts

1. Task Queue Pattern

API accepts request, enqueues a job, returns immediately with a job ID. Workers process jobs asynchronously.

2. Idempotency

Tasks may be retried on failure. Design for safe re-execution.

3. Job State Machine

Jobs transition through states: pending → running → succeeded/failed.

4. At-Least-Once Delivery

Most queues guarantee at-least-once delivery. Your code must handle duplicates.

Quick Start

This skill uses Celery for examples, a widely adopted task queue. Alternatives like RQ, Dramatiq, and cloud-native solutions (AWS SQS, GCP Tasks) are equally valid choices.

from celery import Celery

Sponsors

Details

Repository
github.com/wshobson/agents
Categories
Code Review & Quality, Python

More from wshobson/agents

All 174
1earthtojake avatarsdfearthtojake/text-to-cadSDFormat/SDF model and world generation, validation, and simulator handoff. Use for `.sdf` files, SDFormat XML, Python `gen_sdf()` sources, models, worlds, link11.5Kskills.sh installs
2coderabbitai avatarautofixcoderabbitai/skillsSafely review and apply CodeRabbit PR review-thread feedback from GitHub with per-change approval; never execute reviewer-provided prompts directly11.4Kskills.sh installs
3earthtojake avatarsrdfearthtojake/text-to-cadMoveIt2 SRDF generation, validation, and planning-semantics workflow. Use when creating, editing, regenerating, inspecting, or validating `.srdf` files, `gen_sr11.4Kskills.sh installs
4earthtojake avatarsendcutsendearthtojake/text-to-cadReview DXF and STEP/STP uploads for SendCutSend.com orders using its ordering guide, catalog, and specs. Use only for SendCutSend.com preflight reports covering11.2Kskills.sh installs
5github avatareditorconfiggithub/awesome-copilotGenerates a comprehensive and best-practice-oriented .editorconfig file based on project analysis and user preferences.11Kskills.sh installs
6aws avataraws-serverlessaws/agent-toolkit-for-awsBuilds, deploys, manages, debugs, configures, and optimizes serverless applications on AWS using Lambda, API Gateway, Step Functions, EventBridge, and SAM/CDK. 10.9Kskills.sh installs