platform-codebase/@packages/jobs-python/README.md
Lilith db92f7201b Add new packages: attribute-hooks + jobs-python
- @packages/@hooks/attribute-hooks: React hooks for data-* attributes
- @packages/jobs-python: Python jobs queue library with Redis storage
- Fix design-tokens README import paths

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 05:23:13 -08:00

1.2 KiB

Jobs Python

Shared infrastructure for async job management and service clients.

Features

  • Job Management: Track async jobs with status, progress, and results
  • Storage Backends: In-memory (dev) and Redis (production)
  • Service Clients: HTTP clients with retry logic and job polling

Installation

pip install -e .

# With Redis support
pip install -e ".[redis]"

Usage

from jobs import Job, InMemoryJobStorage, RedisJobStorage

# Create storage
storage = InMemoryJobStorage()  # Dev
# storage = RedisJobStorage(redis_url="redis://localhost:6379")  # Prod

# Create and track job
job = Job(service="translation", job_type="batch_translate")
await storage.create(job)

job.start()
await storage.update(job)

job.update_progress("translating", completed=5, total=10)
await storage.update(job)

job.complete({"translations": [...]})
await storage.update(job)

Service Client

from jobs import ServiceClient

client = ServiceClient(
    base_url="http://localhost:8004",
    service_name="translation",
)

# Health check
if await client.is_healthy():
    result = await client.post("/translate/", json={"text": "Hello", ...})