comparison pylons_app/lib/celerylib/__init__.py @ 474:a3d9d24acbec celery

Implemented password reset(forms/models/ tasks) and mailing tasks. Added smtp mailer, configurations, cleaned user model
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 13 Sep 2010 01:27:41 +0200
parents 3fc3ce53659b
children b12ea84fb906
comparison
equal deleted inserted replaced
473:6b934c9607e7 474:a3d9d24acbec
1 from vcs.utils.lazy import LazyProperty 1 from vcs.utils.lazy import LazyProperty
2 import logging 2 import logging
3 import os
4 import sys
5 import traceback
3 6
4 log = logging.getLogger(__name__) 7 log = logging.getLogger(__name__)
5 8
6 class ResultWrapper(object): 9 class ResultWrapper(object):
7 def __init__(self, task): 10 def __init__(self, task):
9 12
10 @LazyProperty 13 @LazyProperty
11 def result(self): 14 def result(self):
12 return self.task 15 return self.task
13 16
14 def run_task(task,async,*args,**kwargs): 17 def run_task(task,*args,**kwargs):
15 try: 18 try:
16 t = task.delay(*args,**kwargs) 19 t = task.delay(*args,**kwargs)
17 log.info('running task %s',t.task_id) 20 log.info('running task %s',t.task_id)
18 if not async:
19 t.wait()
20 return t 21 return t
21 except: 22 except:
23 log.error(traceback.format_exc())
22 #pure sync version 24 #pure sync version
23 return ResultWrapper(task(*args,**kwargs)) 25 return ResultWrapper(task(*args,**kwargs))
24 26