Skip to content

Commit

Permalink
Improve wait for end of update task in TestSubscription
Browse files Browse the repository at this point in the history
  • Loading branch information
agners committed May 8, 2024
1 parent 77af1f5 commit 479b23a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/controller/python/test/test_scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,9 +1284,18 @@ async def _conductAttributeChange(devCtrl: ChipDeviceCtrl.ChipDeviceController,
"Failed to receive subscription update")
break

# thread changes 5 times, and sleeps for 3 seconds in between.
# Add an additional 3 seconds of slack. Timeout is in seconds.
await asyncio.wait_for(taskAttributeChange, 3)
# At this point the task should really have done the three attribute,
# otherwise something is wrong. Wait for just 1s in case of a race
# condition between the last attribute update and the callback.
try:
await asyncio.wait_for(taskAttributeChange, 1)
except asyncio.TimeoutError:
# If attribute change task did not finish something is wrong. Cancel
# the task.
taskAttributeChange.cancel()
# This will throw a asyncio.CancelledError and makes sure the test
# is declared failed.
await taskAttributeChange

return True if receivedUpdate == 5 else False

Expand Down

0 comments on commit 479b23a

Please sign in to comment.