EventQueueEmptyEventHandler.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:py-enarksh 作者: SetBased 项目源码 文件源码
def __queue_handler(controller):
        """
        Starts a node that is queued and for which there are enough resources available.

        :param enarksh.controller.Controller.Controller controller: The controller.
        """
        # Return immediately if there are no loaded schedules.
        if not controller.schedules:
            return

        start = False
        schedules = sorted(controller.schedules.values(),
                           key=functools.cmp_to_key(EventQueueEmptyEventHandler.queue_compare))
        for schedule in schedules:
            queue = schedule.get_queue()
            for node in queue:
                # Inquire if there are enough resources available for the node.
                start = node.inquire_resources()
                if start:
                    span_job = node.start()

                    # If required send a message to the spanner.
                    if span_job:
                        message = node.get_start_message(schedule.sch_id)
                        controller.message_controller.send_message('spawner', message)
                    else:
                        node.stop(0)

                    # If a node has been started leave inner loop.
                    break

            # If a node has been started leave the outer loop.
            if start:
                break

    # ------------------------------------------------------------------------------------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号