Skip to main content

Celery taskcls decorator

Project description

Celery Decorator taskcls

  • Free software: MIT License


This package is temporary way to get app.taskcls decorator right now. The main target of this package make you able to use taskcls decorator before celery 4.5 released, and then you can remove this package import without application code change

More about:


import celery_decorator_taskcls

from celery import Celery
app = Celery(...)

class BaseTask:
    def __init__(self, task, **kwargs):
        self.task = task
        for key, value in kwargs.items():
            setattr(self, key, value)

    def task(cls, task, **kwargs):
        instance = cls(task, **kwargs)
        return instance.main()

class SimpleTask(BaseTask):
    def main(self):

app.taskcls decorator behavior is the same as app.task. You can pass it kwargs like bind, name or other or you can use it without kwargs

You can also pass default decorator options by nested class MetaTask:

class BaseTask:
    class MetaTask:
        bind = True

    def task(cls, taks, *args, **kwargs):

Patching options

By default patcher search Celery.taskcls attribute. If it not found, patcher creates it. But when it exists (I belive you find it in Celery 4.5), patcher checks its optional argument force, because it seems patching not required. Calling celery_decorator_taskcls.patch_celery(force=True) enforces patching Celery even Celery.taskcls exists



  • Allow to inherit taskcls from another taskcls
  • Comment code blocks to simplify its understanding


  • Fix MetaTask inheritance


  • Update Readme


  • Add chandelog
  • Rename nested class Meta to MetaTask


  • Initial commit

Project details

Download files

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

Files for celery-decorator-taskcls, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size celery_decorator_taskcls-0.1.4-py3-none-any.whl (4.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size celery-decorator-taskcls-0.1.4.tar.gz (3.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page