skillfed

celery-singleton

Prevent duplicate celery tasks

celery-singleton v0.3.1 352.8K downloads/30d#7,310 on PyPI263
Permissive license MIT Abandoned released

What it is and what it does

Celery-Singleton is a base class for Celery tasks that enforces at-most-one-instance semantics: when you call delay() or apply_async() on a singleton task, it either queues a new task or returns the AsyncResult of an already-queued or running task with identical name and arguments. It uses Redis-backed distributed locking with task name and arguments hashed as the lock key, preventing duplicate work from clogging your message broker.

The package works transparently with standard Celery—no special exception handling needed. Locks are held until the task completes (success or failure), then released. You can configure which arguments determine uniqueness via the unique_on parameter, set lock expiry times to handle worker crashes, or raise exceptions on duplicate attempts instead of returning existing results. It requires a Redis server and JSON-serializable task arguments.

Use it for:

  • Prevent duplicate long-running reports or data exports from queuing when users click submit multiple times
  • Ensure only one instance of a periodic cleanup or maintenance task runs at a time across distributed workers
  • Rate-limit task execution by argument (e.g., one sync per user) without time-based delays
  • Protect against thundering herd problems when multiple services trigger the same background job
  • Simplify task deduplication logic by inheriting from Singleton instead of manual lock management

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Prevents duplicate Celery tasks from being queued or running simultaneously by using task name and arguments to determine uniqueness, with Redis-backed distributed locking.

Yes, if you are already committed to Celery and Redis and need simple deduplication without custom locking logic. However, proceed with caution: the package is abandoned (last release 2021-01-14, last commit 2023-06-09), so compatibility with recent Celery versions is unverified and no bug fixes are forthcoming. Evaluate whether a maintained fork or alternative exists before adopting for new projects.

Install

celery-singleton on PyPI

pip

pip install celery-singleton

uv

uv add celery-singleton

poetry

poetry add celery-singleton

Installing celery-singleton

Before you install

Low install friction with only two runtime dependencies (celery and redis). However, the package is abandoned—last release was 2021-01-14 and last commit 2023-06-09—so no active maintenance or bug fixes should be expected.

License in practice

MIT license is permissive, allowing commercial and private use with minimal restrictions, making it safe from a licensing perspective for most projects.

Quickstart

pip install celery-singleton

from celery_singleton import Singleton

@celery_app.task(base=Singleton)
def do_stuff(*args, **kwargs):
    return 'result'

async_result = do_stuff.delay(1, 2, 3, a='b')
async_result2 = do_stuff.delay(1, 2, 3, a='b')
assert async_result == async_result2

Requires a Redis server configured as the Celery result backend (or specified separately via singleton_backend_url config). All task arguments must be JSON serializable.

Verify before relying

  • Whether the package remains compatible with recent Celery versions released after 2023-06-09
  • Whether Redis backend compatibility extends to modern Redis versions and Redis-compatible services
  • Active community forks or maintained alternatives that address the abandoned status

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.6,<4.0)
Install friction low — pure-Python wheel
Runtime dependencies 2 — celery, redis
Maintenance abandoned — 2,038 days since the last release
Last repo commit
First released
Downloads 352,762/month — #7,310 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: celery_singleton-0.3.1-py3-none-any.whl

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

celery duplicate task preventioncelery singleton taskscelery task deduplicationprevent duplicate celery jobscelery distributed lockingcelery task queuing deduplicationcelery one-at-a-time tasks
celery-task-deduplicationdistributed-lockingabandoned-maintenance

More Distributed Computing packages