def pause_multiple_jobs(): job_ids = request.form.getlist("job_id") task_ids_to_stop = [] for job_id in job_ids: job = Job.query.filter_by(id=job_id).first() if not job: return (render_template( "pyfarm/error.html", error="Job %s not found" % job_id), NOT_FOUND) for task in job.tasks: if task.state == WorkState.RUNNING: task_ids_to_stop.append(task.id) job.state = WorkState.PAUSED db.session.add(job) db.session.commit() for task_id in task_ids_to_stop: stop_task.delay(task_id) assign_tasks.delay() flash("Selected jobs will be paused.") if "next" in request.args: return redirect(request.args.get("next"), SEE_OTHER) else: return redirect(url_for("jobs_index_ui"), SEE_OTHER)
def pause_multiple_jobs(): job_ids = request.form.getlist("job_id") task_ids_to_stop = [] for job_id in job_ids: job = Job.query.filter_by(id=job_id).first() if not job: return (render_template("pyfarm/error.html", error="Job %s not found" % job_id), NOT_FOUND) for task in job.tasks: if task.state == WorkState.RUNNING: task_ids_to_stop.append(task.id) job.state = WorkState.PAUSED db.session.add(job) db.session.commit() for task_id in task_ids_to_stop: stop_task.delay(task_id) assign_tasks.delay() flash("Selected jobs will be paused.") if "next" in request.args: return redirect(request.args.get("next"), SEE_OTHER) else: return redirect(url_for("jobs_index_ui"), SEE_OTHER)
def pause_single_job(job_id): job = Job.query.filter_by(id=job_id).first() if not job: return (render_template("pyfarm/error.html", error="Job %s not found" % job_id), NOT_FOUND) job.state = WorkState.PAUSED db.session.add(job) db.session.commit() for task in job.tasks: if task.state == WorkState.RUNNING: stop_task.delay(task.id) assign_tasks.delay() flash("Job %s will be paused." % job.title) if "next" in request.args: return redirect(request.args.get("next"), SEE_OTHER) else: return redirect(url_for("jobs_index_ui"), SEE_OTHER)
def pause_single_job(job_id): job = Job.query.filter_by(id=job_id).first() if not job: return (render_template( "pyfarm/error.html", error="Job %s not found" % job_id), NOT_FOUND) job.state = WorkState.PAUSED db.session.add(job) db.session.commit() for task in job.tasks: if task.state == WorkState.RUNNING: stop_task.delay(task.id) assign_tasks.delay() flash("Job %s will be paused." % job.title) if "next" in request.args: return redirect(request.args.get("next"), SEE_OTHER) else: return redirect(url_for("jobs_index_ui"), SEE_OTHER)