Mercurial > public > sg101
view gpp/core/tasks.py @ 517:666147a2cc08
Moved the imports from the top of the file into the task function. This seemed to prevent some strange import errors that only occurred on the production server. I don't know if the problems were related to mod_wsgi or Python 2.5 or what.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 15 Dec 2011 02:49:16 +0000 |
parents | beda97542da8 |
children | 5171a5e9353b |
line wrap: on
line source
""" Celery tasks for the core application. """ from celery.task import task import django.core.mail @task def add(x, y): """ It is useful to have a test task laying around. This is it. """ return x + y @task def send_mail(subject, message, from_email, recipient_list, **kwargs): """ A task to send mail via Django. """ django.core.mail.send_mail(subject, message, from_email, recipient_list, **kwargs) @task def cleanup(): """ A task to perform site-wide cleanup actions. """ from django.core.management.commands.cleanup import Command as CleanupCommand from forums.management.commands.forum_cleanup import Command as ForumCleanup # Execute Django's cleanup command (deletes old sessions). command = CleanupCommand() command.execute() # Execute our forum cleanup command to delete old last visit records. command = ForumCleanup() command.execute()