def do_job_work(request): init_jobs() try: job = Job.get(request.POST['job_key']) params = request.POST.get('params', '{}') worker = get_worker(job.job_name) if worker['pre_request']: early_response = worker['pre_request'](request) if early_response is not None: return early_response if job.result: result_for_worker = simplejson.loads(job.result) else: result_for_worker = None finished, result = worker['callback'](result_for_worker, simplejson.loads(params)) job.result = simplejson.dumps(result) job.save() except: traceback.print_exc() raise @as_json def data(request): return {'finished': finished, 'success': True} return data(request)
def do_job_work(request): init_jobs() try: job = Job.get(request.POST['job_key']) params = request.POST.get('params', '{}') worker = get_worker(job.job_name) if worker['pre_request']: early_response = worker['pre_request'](request) if early_response is not None: return early_response if job.result: result_for_worker = simplejson.loads(job.result) else: result_for_worker = None finished, result = worker['callback'](result_for_worker, simplejson.loads(params)) job.result = simplejson.dumps(result) job.save() except: traceback.print_exc() raise @as_json def data(request): return { 'finished': finished, 'success': True } return data(request)
def start_job(request): init_jobs() # TODO(kumar) check for already running jobs reap_dead_jobs() job_name = request.POST['job_name'] job = Job(job_name=job_name) job.put() worker = get_worker(job_name) if worker['pre_request']: early_response = worker['pre_request'](request) if early_response is not None: return early_response @as_json def data(request): return {'job_key': str(job.key()), 'success': True} return data(request)
def start_job(request): init_jobs() # TODO(kumar) check for already running jobs reap_dead_jobs() job_name = request.POST['job_name'] job = Job(job_name=job_name) job.put() worker = get_worker(job_name) if worker['pre_request']: early_response = worker['pre_request'](request) if early_response is not None: return early_response @as_json def data(request): return { 'job_key': str(job.key()), 'success': True } return data(request)