def run(self, request, pk=None): try: task = self.get_object() taskrun = task.start() return Response({'message': 'OK','taskrun_pk': taskrun.pk}) except Exception, exc: return build_exception_response()
def task_progress_consumer(message): taskrun = TaskRun.objects.get(pk=message.content['taskrun_pk']) progress = message.content.get('progress', None) if progress is not None: taskrun.advance(progress, result=message.content.get('result', None)) try: taskrun.task.downcast.progress(taskrun) except Exception, exc: taskrun.fail(build_exception_response().data)
def task_progress_consumer(message): taskrun = TaskRun.objects.get(pk=message.content['taskrun_pk']) progress = message.content.get('progress',None) if progress is not None: taskrun.advance(progress,result=message.content.get('result',None)) try: taskrun.task.downcast.progress(taskrun) except Exception, exc: taskrun.fail(build_exception_response().data)
def start(self): if self.max_run > 0 and self.running_count >= self.max_run: raise Exception(build_error_response(RESPERR.TOO_MANY_RUNS).data) taskrun = TaskRun.objects.create(task=self) try: if self. async: Channel('task-run').send({'taskrun_pk': taskrun.pk}) else: self.downcast.run(taskrun) except Exception, exc: taskrun.fail(build_exception_response().data)
def start(self): if self.max_run > 0 and self.running_count >= self.max_run: raise Exception(build_error_response(RESPERR.TOO_MANY_RUNS).data) taskrun = TaskRun.objects.create(task=self) try: if self.async: Channel('task-run').send({'taskrun_pk': taskrun.pk}) else: self.downcast.run(taskrun) except Exception, exc: taskrun.fail(build_exception_response().data)
def task_run_consumer(message): taskrun = TaskRun.objects.get(pk=message.content['taskrun_pk']) try: taskrun.task.downcast.run(taskrun) except Exception, exc: taskrun.fail(build_exception_response().data)