Skip to content

Commit 0246d05

Browse files
committed
[Python] Use CallAsync where appropriate
1 parent b8c632e commit 0246d05

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/controller/python/chip/ChipDeviceCtrl.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -991,13 +991,14 @@ async def SendCommand(self, nodeid: int, endpoint: int, payload: ClusterObjects.
991991
future = eventLoop.create_future()
992992

993993
device = await self.GetConnectedDevice(nodeid, timeoutMs=interactionTimeoutMs)
994-
ClusterCommand.SendCommand(
994+
res = await ClusterCommand.SendCommand(
995995
future, eventLoop, responseType, device.deviceProxy, ClusterCommand.CommandPath(
996996
EndpointId=endpoint,
997997
ClusterId=payload.cluster_id,
998998
CommandId=payload.command_id,
999999
), payload, timedRequestTimeoutMs=timedRequestTimeoutMs,
1000-
interactionTimeoutMs=interactionTimeoutMs, busyWaitMs=busyWaitMs, suppressResponse=suppressResponse).raise_on_error()
1000+
interactionTimeoutMs=interactionTimeoutMs, busyWaitMs=busyWaitMs, suppressResponse=suppressResponse)
1001+
res.raise_on_error()
10011002
return await future
10021003

10031004
async def SendBatchCommands(self, nodeid: int, commands: typing.List[ClusterCommand.InvokeRequestInfo],

src/controller/python/chip/clusters/Command.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def TestOnlySendCommandTimedRequestFlagWithNoTimedInvoke(future: Future, eventLo
291291
))
292292

293293

294-
def SendCommand(future: Future, eventLoop, responseType: Type, device, commandPath: CommandPath, payload: ClusterCommand,
294+
async def SendCommand(future: Future, eventLoop, responseType: Type, device, commandPath: CommandPath, payload: ClusterCommand,
295295
timedRequestTimeoutMs: Union[None, int] = None, interactionTimeoutMs: Union[None, int] = None, busyWaitMs: Union[None, int] = None,
296296
suppressResponse: Union[None, bool] = None) -> PyChipError:
297297
''' Send a cluster-object encapsulated command to a device and does the following:
@@ -316,7 +316,7 @@ def SendCommand(future: Future, eventLoop, responseType: Type, device, commandPa
316316

317317
payloadTLV = payload.ToTLV()
318318
ctypes.pythonapi.Py_IncRef(ctypes.py_object(transaction))
319-
return builtins.chipStack.Call(
319+
return await builtins.chipStack.CallAsync(
320320
lambda: handle.pychip_CommandSender_SendCommand(
321321
ctypes.py_object(transaction), device,
322322
c_uint16(0 if timedRequestTimeoutMs is None else timedRequestTimeoutMs), commandPath.EndpointId,

0 commit comments

Comments
 (0)