pmclanahan / django-celery-email

A Django email backend that uses a celery task for sending the email.
BSD 3-Clause "New" or "Revised" License
477 stars 108 forks source link

How to set celery.base #20

Closed oppianmatt closed 8 years ago

oppianmatt commented 9 years ago

I have an abstract celery base Task for adding extra logging with our celery tasks. Like so:

@task(queue='email', base=LoggingTask)
def foo()
...

But I can't set that in the settings, can't import it since it imports celery which causes circular import and can't use a string.

CELERY_EMAIL_TASK_CONFIG = {
    # we want emails to be high priority
    'queue': 'emails',
    # can also configure rate limit
    # 'rate_limit': '50/m',
    'ignore_result': True,
    # extra logging
    'base': 'celeryutils.LoggingTask',
}

http://celery.readthedocs.org/en/latest/userguide/tasks.html#abstract-classes

pmclanahan commented 9 years ago

Ah yes. We could use django.utils.module_loading.import_string if we see a string in the base kwarg. I'd be nice if celery supported this out of the box, but this is easy enough to do here. Are you interested in working on this?

oppianmatt commented 9 years ago

yeah I could knock up a pull request easy enough.