Skip to content

Commit 6092e8a

Browse files
authored
[Python] Drop network lock (#33720)
The network lock is not needed in the Python controller, as all calls to the SDK are made by posting to the Matter SDK event loop through ScheduleWork(), hence are guaranteed to be serialized. From how I understand ScheduleWork() works, it pushes the work to the event loop through PostEvent() which at least on POSIX is using the thread safe device queue (see GenericPlatformManagerImpl_POSIX.cpp).
1 parent 4ec2035 commit 6092e8a

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/controller/python/chip/ChipStack.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ class ChipStack(object):
144144
def __init__(self, persistentStoragePath: str, enableServerInteractions=True):
145145
builtins.enableDebugMode = False
146146

147-
# TODO: Probably no longer necessary, see https://github.com/project-chip/connectedhomeip/issues/33321.
148-
self.networkLock = Lock()
149147
self.completeEvent = Event()
150148
self.commissioningCompleteEvent = Event()
151149
self._ChipStackLib = None
@@ -212,7 +210,6 @@ def Shutdown(self):
212210
# #20437 tracks consolidating these.
213211
#
214212
self._ChipStackLib.pychip_CommonStackShutdown()
215-
self.networkLock = None
216213
self.completeEvent = None
217214
self._ChipStackLib = None
218215
self._chipDLLPath = None
@@ -226,10 +223,7 @@ def Call(self, callFunct, timeoutMs: int = None):
226223
This function is a wrapper of PostTaskOnChipThread, which includes some handling of application specific logics.
227224
Calling this function on CHIP on CHIP mainloop thread will cause deadlock.
228225
'''
229-
# TODO: Lock probably no longer necessary, see https://github.com/project-chip/connectedhomeip/issues/33321.
230-
with self.networkLock:
231-
res = self.PostTaskOnChipThread(callFunct).Wait(timeoutMs)
232-
return res
226+
return self.PostTaskOnChipThread(callFunct).Wait(timeoutMs)
233227

234228
async def CallAsync(self, callFunct, timeoutMs: int = None):
235229
'''Run a Python function on CHIP stack, and wait for the response.
@@ -256,9 +250,7 @@ def CallAsyncWithCompleteCallback(self, callFunct):
256250
# throw error if op in progress
257251
self.callbackRes = None
258252
self.completeEvent.clear()
259-
# TODO: Lock probably no longer necessary, see https://github.com/project-chip/connectedhomeip/issues/33321.
260-
with self.networkLock:
261-
res = self.PostTaskOnChipThread(callFunct).Wait()
253+
res = self.PostTaskOnChipThread(callFunct).Wait()
262254

263255
if not res.is_success:
264256
self.completeEvent.set()

0 commit comments

Comments
 (0)