> 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/wait-for-done.md).

# wait\_for\_done 方法

## 简要

等待与当前可等待操作相关的操作完成。在可等待操作完成或超时之前，该方法不会返回。

```python
def wait_for_done(self,
    max_wait_seconds: float = 15
) -> object
```

## 参数

该方法具有以下参数，其参数、参数类型和参数描述如下：

| 参数                 | 类型    | 必选 | 描述                                                                                  |
| ------------------ | ----- | -- | ----------------------------------------------------------------------------------- |
| max\_wait\_seconds | float | 否  | <p>最长等待秒数。</p><p>如果该参数被忽略，默认值为 15 秒。</p><p>如果该参数被设置为 <code>None</code>，则直到操作完成。</p> |

## 返回值

该方法返回包含与之关联的可等待操作结果的 Object 实例。

## 异常

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

#### ValueError

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

#### TimeoutError

已超出可等待操作的最长等待时间。

## 示例

接下来我们将通过一段 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
