Skip to content

Commit 84e2a26

Browse files
author
Jim Bennett
committed
Adding correct retry wait
1 parent adaa635 commit 84e2a26

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

adafruit_azureiot/device_registration.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ def _handle_dps_update(self, client, topic: str, msg: str) -> None:
8787
message = json.loads(msg)
8888

8989
if topic.startswith("$dps/registrations/res/202"):
90+
# Get the retry after and wait for that before responding
91+
parts = str.split(topic, "retry-after=")
92+
waittime = int(parts[1])
93+
94+
self._logger.debug(f"Retrying after {waittime}s")
95+
96+
time.sleep(waittime)
9097
self._operation_id = message["operationId"]
9198
elif topic.startswith("$dps/registrations/res/200"):
9299
self._hostname = message["registrationState"]["assignedHub"]

0 commit comments

Comments
 (0)