當前位置: 首頁>>代碼示例>>Python>>正文


Python Result.error方法代碼示例

本文整理匯總了Python中result.Result.error方法的典型用法代碼示例。如果您正苦於以下問題:Python Result.error方法的具體用法?Python Result.error怎麽用?Python Result.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在result.Result的用法示例。


在下文中一共展示了Result.error方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_filters

# 需要導入模塊: from result import Result [as 別名]
# 或者: from result.Result import error [as 別名]
    def run_filters(self, filters, hostIDs, vmID, properties_map):
        result = Result()
        request_id = str(uuid.uuid1())
        log_adapter = \
            utils.RequestAdapter(self._logger,
                                 {'method': 'run_filters',
                                            'request_id': request_id})

        # run each filter in a process for robustness
        log_adapter.info("got request: %s" % str(filters))
        avail_f, missing_f = utils.partition(filters,
                                             lambda f: f in self._filters)

        # handle missing filters
        for f in missing_f:
            log_adapter.warning("Filter requested but was not found: %s" % f)
            result.pluginError(f, "plugin not found: '%s'" % f)

        # Prepare a generator "list" of runners
        filterRunners = [
            PythonMethodRunner(
                self._pluginDir,
                self._class_to_module_map[f],
                f,
                utils.FILTER,
                (hostIDs, vmID, properties_map),
                request_id)
            for f in avail_f
        ]

        for runner in filterRunners:
            runner.start()

        log_adapter.debug("Waiting for filters to finish")
        # TODO add timeout config
        if utils.waitOnGroup(filterRunners):
            log_adapter.warning("Waiting on filters timed out")

        log_adapter.debug("Aggregating results")
        filters_results = self.aggregate_filter_results(filterRunners,
                                                        request_id)
        if filters_results is None:
            log_adapter.info('All filters failed, return the full list')
            result.error("all filters failed")
            filters_results = hostIDs

        result.add(filters_results)
        log_adapter.info('returning: %s' % str(filters_results))

        return result
開發者ID:oVirt,項目名稱:ovirt-scheduler-proxy,代碼行數:52,代碼來源:request_handler.py

示例2: run_cost_functions

# 需要導入模塊: from result import Result [as 別名]
# 或者: from result.Result import error [as 別名]
    def run_cost_functions(self,
                           cost_functions,
                           hostIDs,
                           vmID,
                           properties_map):
        result = Result()
        request_id = str(uuid.uuid1())
        log_adapter = \
            utils.RequestAdapter(self._logger,
                                 {'method': 'run_cost_functions',
                                            'request_id': request_id})

        # run each filter in a process for robustness
        log_adapter.info("got request: %s" % str(cost_functions))

        # Get the list of known and unknown score functions
        available_cost_f, missing_cost_f = \
            utils.partition(cost_functions, lambda (n, w): n in self._scores)

        # Report the unknown functions
        for name, weight in missing_cost_f:
                log_adapter.warning("requested but was not found: %s" % name)
                result.pluginError(name, "plugin not found: '%s'" % name)

        # Prepare a generator "list" with runners and weights
        scoreRunners = [
            (PythonMethodRunner(
                self._pluginDir,
                self._class_to_module_map[name],
                name,
                utils.SCORE,
                (hostIDs, vmID, properties_map),
                request_id), weight)
            for name, weight in available_cost_f
        ]

        for runner, _weight in scoreRunners:
            runner.start()

        log_adapter.debug("Waiting for scoring to finish")
        if utils.waitOnGroup([runner for runner, _weight in scoreRunners]):
            log_adapter.warning("Waiting on score functions timed out")
            result.error("Waiting on score functions timed out")

        log_adapter.debug("Aggregating results")
        results = self.aggregate_score_results(scoreRunners, request_id)
        result.add(results)
        log_adapter.info('returning: %s' % str(results))
        return result
開發者ID:oVirt,項目名稱:ovirt-scheduler-proxy,代碼行數:51,代碼來源:request_handler.py


注:本文中的result.Result.error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。