comparison core/tasks.py @ 750:aeafbf3ecebf

For #63, upgrade to celery 3.1.7.
author Brian Neal <bgneal@gmail.com>
date Tue, 31 Dec 2013 16:36:22 -0600
parents 53a56d19568c
children 79a71b9d0a2a
comparison
equal deleted inserted replaced
749:b6e98717690b 750:aeafbf3ecebf
1 """ 1 """
2 Celery tasks for the core application. 2 Celery tasks for the core application.
3 3
4 """ 4 """
5 from celery.task import task 5 from __future__ import absolute_import
6
7 from celery import shared_task
6 import django.core.mail 8 import django.core.mail
7 9
8 import core.whos_online 10 import core.whos_online
9 11
10 12
11 @task 13 @shared_task
12 def add(x, y):
13 """
14 It is useful to have a test task laying around. This is it.
15
16 """
17 return x + y
18
19
20 @task
21 def send_mail(subject, message, from_email, recipient_list, **kwargs): 14 def send_mail(subject, message, from_email, recipient_list, **kwargs):
22 """ 15 """
23 A task to send mail via Django. 16 A task to send mail via Django.
24 17
25 """ 18 """
26 django.core.mail.send_mail(subject, message, from_email, recipient_list, 19 django.core.mail.send_mail(subject, message, from_email, recipient_list,
27 **kwargs) 20 **kwargs)
28 21
29 22
30 @task 23 @shared_task
31 def cleanup(): 24 def cleanup():
32 """ 25 """
33 A task to perform site-wide cleanup actions. 26 A task to perform site-wide cleanup actions.
34 27
35 """ 28 """
49 42
50 command = forum_cleanup.Command() 43 command = forum_cleanup.Command()
51 command.execute() 44 command.execute()
52 45
53 46
54 @task 47 @shared_task
55 def max_users(): 48 def max_users():
56 """ 49 """
57 Run the periodic task to calculate the who's online max users/visitors 50 Run the periodic task to calculate the who's online max users/visitors
58 statistics. 51 statistics.
59 52