当前位置: 首页>>代码示例>>Python>>正文


Python TaskApi.dispatch_tasks方法代码示例

本文整理汇总了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
开发者ID:pedromaltez-forks,项目名称:flamenco,代码行数:27,代码来源:__init__.py

示例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()
开发者ID:msimoncz,项目名称:brender,代码行数:13,代码来源:__init__.py

示例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))
开发者ID:Anuga,项目名称:flamenco,代码行数:14,代码来源:__init__.py

示例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))
开发者ID:EVMosaic,项目名称:flamenco,代码行数:18,代码来源:__init__.py

示例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
开发者ID:msimoncz,项目名称:brender,代码行数:19,代码来源:__init__.py

示例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
开发者ID:msimoncz,项目名称:brender,代码行数:25,代码来源:__init__.py


注:本文中的application.modules.tasks.TaskApi.dispatch_tasks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。