Esempio n. 1
0
    def initialize(self):
        if self.running:
            raise errors.SchedulerError('schedulre already running')

        #1. 加载scheduler配置
        self._threadpool = ThreadPool(**const.DEFAULT_THREADPOOL_CONFIG)


        #2. 加载job配置文件
        yaml_data = utils.parse_yaml_from_file(self.job_file)
        assert isinstance(yaml_data, list), 'job config yaml file should be list'
        for job_config in yaml_data:
            job_wrap = JobWrap(job_config)
            trigger_type, kwargs = job_wrap.get_trigger()
            assert trigger_type in TRIGGER_MAP
            getattr(self, TRIGGER_MAP[trigger_type])(**kwargs)


        self._initialized = True