comparison pylons_app/lib/celerylib/__init__.py @ 467:3fc3ce53659b celery

starting celery branch
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 11 Sep 2010 01:55:46 +0200
parents
children a3d9d24acbec
comparison
equal deleted inserted replaced
466:183cee110578 467:3fc3ce53659b
1 from vcs.utils.lazy import LazyProperty
2 import logging
3
4 log = logging.getLogger(__name__)
5
6 class ResultWrapper(object):
7 def __init__(self, task):
8 self.task = task
9
10 @LazyProperty
11 def result(self):
12 return self.task
13
14 def run_task(task,async,*args,**kwargs):
15 try:
16 t = task.delay(*args,**kwargs)
17 log.info('running task %s',t.task_id)
18 if not async:
19 t.wait()
20 return t
21 except:
22 #pure sync version
23 return ResultWrapper(task(*args,**kwargs))
24