fix(protocol): pace CoAP request sends

This commit is contained in:
Jason Morcos
2026-08-18 14:25:10 -07:00
parent 0722c552c9
commit 0d9d13b8fb
2 changed files with 175 additions and 2 deletions
+6 -2
View File
@@ -879,8 +879,8 @@ class DtlsCoapSession:
deadline = time.time() + timeout
szx = BLOCK_SZX # server may negotiate down; track per-transfer
while True:
if num > 0:
self.pace()
self.pace()
self._check_live()
container = self._exchange_block(
tok, path_segs, query, num, szx, deadline)
if 'err' in container:
@@ -1026,6 +1026,8 @@ class DtlsCoapSession:
with self._state_lock:
self._pending[tok] = (ev, container)
try:
self.pace()
self._check_live()
self._send_dgram(datagram)
if not ev.wait(timeout):
raise SessionTimeoutError()
@@ -1089,6 +1091,8 @@ class DtlsCoapSession:
Returns the token used (in case the caller wants to deregister
later)."""
self._check_live()
self.pace()
self._check_live()
tok = self._next_observe_tok()
href = '/' + '/'.join(path_segs)
# Register the token BEFORE sending — otherwise the device