Skip to content

Commit cedd31b

Browse files
pi-anlandrewleech
authored andcommitted
aioble/security: Only schedule save when needed.
Was getting occasional: RuntimeError: schedule queue full
1 parent dbb3b45 commit cedd31b

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

micropython/bluetooth/aioble/aioble/security.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ def _save_secrets(arg=None):
5757

5858
_path = _path or _DEFAULT_PATH
5959

60-
if not _modified:
61-
# Only save if the secrets changed.
62-
return
63-
6460
with open(_path, "w") as f:
6561
# Convert bytes to hex strings (otherwise JSON will treat them like
6662
# strings).
@@ -106,8 +102,9 @@ def _security_irq(event, data):
106102
_secrets[key] = value
107103

108104
# Queue up a save (don't synchronously write to flash).
109-
_modified = True
110-
schedule(_save_secrets, None)
105+
if not _modified:
106+
_modified = True
107+
schedule(_save_secrets, None)
111108

112109
return True
113110

0 commit comments

Comments
 (0)