# get\_function\_results 方法

## 简要

获取给定无服务器云函数的运行结果，该方法将尝试检索符合条件的所有运行结果记录。

```python
def get_function_results(self,
    region_id: str,
    namespace_name: str,
    function_name: str,
    requirement_context: dict = None,
    function_version: str = None
) -> object
```

## 参数

该方法的参数和参数描述如下：

| 参数                   | 类型                                                                                                                                      | 必选 | 描述                                         |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | -- | ------------------------------------------ |
| region\_id           | str                                                                                                                                     | 是  | 获取的无服务器云函数所在数据中心的唯一标识符。                    |
| namespace\_name      | str                                                                                                                                     | 是  | 获取的无服务器云函数所在命名空间的名称。                       |
| function\_name       | str                                                                                                                                     | 是  | 获取的无服务器云函数名称。                              |
| requirement\_context | [FunctionResultFilter](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/data-types/function-result-filter) | 否  | 过滤符号条件的无服务器云函数运行结果的过滤器上下文字典实例。             |
| function\_version    | str                                                                                                                                     | 否  | 获取的无服务器云函数的版本名称。如果该参数被忽略或设置为 None，默认为最新版本。 |

## 返回值

该方法返回一个用于遍历获取符合过滤条件的无服务器云函数运行结果的生成器实例，生成器实例每次迭代返回包含无服务器云函数运行结果的字典实例，其数据类型为 [FunctionResult](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/data-types/function-result)。

{% hint style="info" %}
该方法在内部维护一个缓冲循环，每次使用 Tencent Cloud API 检索并获取 100 条符合条件的无服务器云函数运行结果。
{% endhint %}

## 异常

该方法可能会主动引发以下异常：

#### ValueError

参数值或类型不符合预期。

#### ActionError

Tencent Cloud API 错误。例如访问凭据无效、给定无服务器云函数不存在等均会引发该异常。

## 示例

下面我们将通过一段 Python 代码向您演示如何使用该方法：

```python
function_results = function_client.get_function_results(
    region_id = 'ap-shanghai',
    namespace_name = 'default',
    function_name = 'addend',
    requirement_context = {
        'type': functions.FunctionResultType.Succeed
    },
    function_version = '1'
)

# Don't worry, this method won't retrieve and get
# all the running results at this time.

for result in function_results:
    print(result['request_id'])
```

## 适用于

#### Tencent Cloud SDK for Python

产品软件包：tencent-cloud-sdk-serverless-functions >= 0.1.1


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/serverless-functions/class-and-method/client/get-function-results.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
