Skip to content

Commit

Permalink
CTAP: Retry on channel busy
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Sep 3, 2024
1 parent d5192a9 commit 0781dbd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fido2/hid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ def call(
on_keepalive: Optional[Callable[[int], None]] = None,
) -> bytes:
event = event or Event()

while True:
try:
return self._do_call(cmd, data, event, on_keepalive)
except CtapError as e:
if e.code == CtapError.ERR.CHANNEL_BUSY:
if not event.wait(0.1):
logger.warning("CTAP channel busy, trying again...")
continue # Keep retrying on BUSY while not cancelled
raise

def _do_call(self, cmd, data, event, on_keepalive):
remaining = data
seq = 0

Expand Down

0 comments on commit 0781dbd

Please sign in to comment.