> For the complete documentation index, see [llms.txt](https://smallso.gitbook.io/tencent-cloud-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/other-products/class-and-method/waitable.md).

# Waitable 类

## 简要

代表一个可等待操作对象的基本类型。借助可等待对象，开发者可以以同步或异步面向对象编程的方式等待一个异步操作真正地完成，例如同步等待一个或多个无服务器云函数资源创建完成。

```python
class Waitable
```

## 属性

可等待操作对象类型的实例包含可公开访问的属性如下：

| 属性     | 类型     | 只读 | 描述                                                                                                                                                                           |
| ------ | ------ | -- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| status | int    | 是  | <p>指示可等待操作对象的状态。<br>与该属性的值相关的是 <a href="https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/other-products/data-types/waitable-status-enum">WaitableStatus</a> 枚举器。</p> |
| result | object | 是  | <p>指示可等待操作对象对应的可等待操作的返回值。</p><p>如果可等待操作没有返回值，该属性的值默认为 <code>None</code>。</p>                                                                                                 |

{% content-ref url="/pages/-M4Ew8JBuUQpHicQhSvL" %}
[WaitableStatus 枚举器](/tencent-cloud-sdk/python-docs/other-products/data-types/waitable-status-enum.md)
{% endcontent-ref %}

## 示例

在下文中我们将通过一段 Python 代码片段向您演示如何使用可等待操作对象：

```python
from tencent.cloud.core import errors
from tencent.cloud.core import waitable
from tencent.cloud.serverless import functions

def main():
    client: functions.Client = functions.fetch_client()

    create_operation: waitable.Waitable = client.create_layer(
        region_id = 'ap-shanghai',
        layer_name = 'default',
        layer_description = 'default layer',
        layer_content = functions.LayerContent().use_local_zip_archive(
            local_file_path = './layer.zip'
        ),
        layer_runtimes = [
            functions.FunctionRuntime.Python
        ],
        layer_license = 'default license'
    )

    try:
        layer_version: int = create_operation.wait_for_done(
            max_wait_seconds = 15
        )
    except TimeoutError:
        print('error: max time limit exceeded when creating layer resource')
        return
    
    print('info: layer version = {LAYER_VERSION}'.format(
        LAYER_VERSION = layer_version
    ))

if __name__ == '__main__':
    main()
```

## 适用于

#### Tencent Cloud SDK for Python

产品软件包：tencent-cloud-sdk-core >= 0.1.5


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://smallso.gitbook.io/tencent-cloud-sdk/python-docs/other-products/class-and-method/waitable.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
