本文整理汇总了Python中application.modules.tasks.TaskApi.dispatch_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python TaskApi.dispatch_tasks方法的具体用法?Python TaskApi.dispatch_tasks怎么用?Python TaskApi.dispatch_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类application.modules.tasks.TaskApi
的用法示例。
在下文中一共展示了TaskApi.dispatch_tasks方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: respawn
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import dispatch_tasks [as 别名]
def respawn(self, job_id):
job = Job.query.get(job_id)
if job:
if job.status == 'active':
self.stop(job_id)
tasks = db.session.query(Task).filter(
Task.job_id == job_id, Task.status.notin_(
['completed','failed'])).all()
best_managers = db.session.query(Manager).join(
JobManagers, Manager.id == JobManagers.manager_id)\
.filter(JobManagers.job_id == job_id)\
.filter(Manager.has_virtual_workers == 1)\
.first()
if best_managers:
fun = partial(TaskApi.start_task, best_managers)
map(fun, tasks)
else:
map(lambda t : setattr(t, 'status', 'waiting'), tasks)
db.session.commit()
TaskApi.dispatch_tasks()
else:
logging.error('Job %d not found' % job_id)
raise KeyError
示例2: start
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import dispatch_tasks [as 别名]
def start(job_id):
job = Job.query.get(job_id)
if job.status != 'running':
job.status = 'running'
db.session.add(job)
db.session.commit()
logging.info('Dispatching tasks')
else:
pass
# TODO (fsiddi): proper error message if jobs is already running
TaskApi.dispatch_tasks()
示例3: patch
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import dispatch_tasks [as 别名]
def patch(self, manager_id):
from application.modules.tasks import TaskApi
args = parser_manager.parse_args()
manager = Manager.query.get_or_404(manager_id)
# TODO add try except statement to safely handle .one() query
manager.total_workers = args['total_workers']
db.session.add(manager)
db.session.commit()
TaskApi.dispatch_tasks()
return jsonify(dict(total_workers=manager.total_workers))
示例4: patch
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import dispatch_tasks [as 别名]
def patch(self, manager_uuid):
from application.modules.tasks import TaskApi
args = parser.parse_args()
try:
manager = Manager.query.filter_by(uuid=manager_uuid).one()
except NoResultFound:
logging.warning("No manager found in Database")
return '', 404
# TODO add try except statement to safely handle .one() query
manager.total_workers = args['total_workers']
db.session.add(manager)
db.session.commit()
TaskApi.dispatch_tasks()
return jsonify(dict(total_workers=manager.total_workers))
示例5: respawn
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import dispatch_tasks [as 别名]
def respawn(self, job_id):
job = Job.query.get(job_id)
if job:
if job.status == 'running':
self.stop(job_id)
tasks = db.session.query(Task).filter(Task.job_id == job_id, Task.status.notin_(['finished','failed']))
best_managers = filter(lambda m : m.total_workers is None, app.config['MANAGERS'])
if best_managers:
fun = partial(TaskApi.start_task, best_managers[0])
map(fun, tasks)
else:
TaskApi.dispatch_tasks(job_id)
else:
logging.error('Job %d not found' % job_id)
raise KeyError
示例6: post
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import dispatch_tasks [as 别名]
def post(self):
args = job_parser.parse_args()
job = Job(
project_id=args['project_id'],
frame_start=args['frame_start'],
frame_end=args['frame_end'],
chunk_size=args['chunk_size'],
current_frame=args['current_frame'],
filepath=args['filepath'],
name=args['job_name'],
render_settings=args['render_settings'],
format=args['format'],
status=args['status'],
priority=args['priority'])
db.session.add(job)
db.session.commit()
logging.info('Parsing job to create tasks')
TaskApi.create_tasks(job)
logging.info('Refresh list of available workers')
TaskApi.dispatch_tasks(job.id)
return job, 201