Skip to content

Commit

Permalink
Add comments about lock
Browse files Browse the repository at this point in the history
  • Loading branch information
agners committed May 6, 2024
1 parent 2a36e34 commit 6c69159
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/controller/python/chip/ChipStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def __init__(self, persistentStoragePath: str, installDefaultLogHandler=True,
bluetoothAdapter=None, enableServerInteractions=True):
builtins.enableDebugMode = False

# TODO: Probably no longer necessary, see https://github.com/project-chip/connectedhomeip/issues/33321.
self.networkLock = Lock()
self.completeEvent = Event()
self.commissioningCompleteEvent = Event()
Expand Down Expand Up @@ -348,6 +349,7 @@ def setLogFunct(self, logFunct):
logFunct = 0
if not isinstance(logFunct, _LogMessageFunct):
logFunct = _LogMessageFunct(logFunct)
# TODO: Lock probably no longer necessary, see https://github.com/project-chip/connectedhomeip/issues/33321.
with self.networkLock:
# NOTE: ChipStack must hold a reference to the CFUNCTYPE object while it is
# set. Otherwise it may get garbage collected, and logging calls from the
Expand Down Expand Up @@ -390,6 +392,7 @@ def Call(self, callFunct, timeoutMs: int = None):
# throw error if op in progress
self.callbackRes = None
self.completeEvent.clear()
# TODO: Lock probably no longer necessary, see https://github.com/project-chip/connectedhomeip/issues/33321.
with self.networkLock:
res = self.PostTaskOnChipThread(callFunct).Wait(timeoutMs)
self.completeEvent.set()
Expand Down Expand Up @@ -422,6 +425,7 @@ def CallAsyncWithCompleteCallback(self, callFunct):
# throw error if op in progress
self.callbackRes = None
self.completeEvent.clear()
# TODO: Lock probably no longer necessary, see https://github.com/project-chip/connectedhomeip/issues/33321.
with self.networkLock:
res = self.PostTaskOnChipThread(callFunct).Wait()

Expand Down

0 comments on commit 6c69159

Please sign in to comment.