Skip to main content

A Redis Backend for Celery with Polling

Project description

Celery Redis Poll Backend

A specialized Redis backend for Celery that replaces the default pub/sub mechanism for task result retrieval with a polling-based approach.

Why Polling Instead of Pub/Sub?

The default Celery Redis backend uses Redis pub/sub for real-time task result notifications. While pub/sub provides immediate updates, it can face challenges in certain scenarios:

  • High memory usage in Redis due to pub/sub channel maintenance
  • Connection stability issues in distributed environments
  • Potential message loss during network interruptions
  • Scaling limitations with large numbers of subscribers

This backend provides a more robust alternative by using a polling mechanism instead.

Features

  • Polling-Based Results: Replaces pub/sub with an efficient polling mechanism for task result retrieval
  • Compatible with Existing Code: Drop-in replacement for the standard Redis backend
  • Configurable Polling: Adjust polling intervals and timeouts to match your needs
  • Resource Efficient: Reduces Redis memory usage by eliminating pub/sub channels
  • Network Friendly: Better handles network interruptions and reconnections

Installation

pip install celery-redis-poll

Usage

Configure your Celery application to use the polling backend:

from celery import Celery

from celery_redis_poll import install_redis_poll_backend

# Registers the polling backend
install_redis_poll_backend()

app = Celery('your_app',
             broker='redis://localhost:6379/0',
             backend='redispoll://localhost:6379/0')

For clustered Redis, use redisclusterpoll instead of redispoll.

Configuration Options

app.conf.update(
    # How often to poll for results (in seconds)
    redis_poll_interval=0.5,
    
    # Maximum time to poll for a result (in seconds)
    redis_poll_timeout=3600,
    
    # Standard Redis options are also supported
    redis_socket_timeout=30.0,
    redis_socket_connect_timeout=30.0,
)

Requirements

  • Python >= 3.7
  • Celery >= 5.0.0
  • Redis >= 4.5.0
  • celery-redis-cluster >= 0.1.6

Development

For development, install extra dependencies:

pip install celery-redis-poll[dev]

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

celery_redis_poll-0.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

celery_redis_poll-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file celery_redis_poll-0.1.1.tar.gz.

File metadata

  • Download URL: celery_redis_poll-0.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for celery_redis_poll-0.1.1.tar.gz
Algorithm Hash digest
SHA256 283115880304261975b9768c081bd85b39d772b81fa4adfc01b457fa0fa12adf
MD5 cca6bbd3a0818737e2faf07122fe73a3
BLAKE2b-256 ff648a3f9c9ed47701ac272cc62402b5fc0078949ad89d0b095282a9fb83794b

See more details on using hashes here.

File details

Details for the file celery_redis_poll-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for celery_redis_poll-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbc387b997ed1077e0bda0f9c0a04d57571a86a136cfe05c41191fa800c4e4e5
MD5 8ff8e5b7f20fff18feabd86bce3c9ab6
BLAKE2b-256 264e4c515ee6ff6f4f565fe9c9b99297726d33bc343719c19365e0cbf0398508

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page