---
title: 函数：synchronize_device_with_timeout
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/runtimeapi/aclpythondevg_01_1028.html
sourcePath: /source/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_1028.html
indexId: 1a2eb79188757c2efd95109dffc6a17e94986e8251ebb16270b014501d4180a571
---
# 函数：synchronize_device_with_timeout

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |


#### 功能说明

阻塞应用程序运行，直到正在运算中的Device完成运算。该接口是在synchronize_device接口基础上进行了增强，支持用户设置超时时间，当应用程序异常时可根据所设置的超时时间自行退出，超时退出时本接口返回ACL_ERROR_RT_STREAM_SYNC_TIMEOUT。

多Device场景下，调用该接口等待的是当前Context对应的Device。


#### 函数原型

- C函数原型
  1 aclError aclrtSynchronizeDeviceWithTimeout(int32_t timeout)

- python函数
  1 ret = acl.rt.synchronize_device_with_timeout(timeout)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| timeout | int，接口的超时时间。 取值说明如下： \-1：表示永久等待，和接口synchronize\_device功能一样； >0：配置具体的超时时间，单位是毫秒。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| ret | int，错误码，返回0表示成功，返回其它值表示失败。 |
