Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Drop network lock #33720

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/controller/python/chip/ChipStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ class ChipStack(object):
def __init__(self, persistentStoragePath: str, 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()
self._ChipStackLib = None
Expand Down Expand Up @@ -212,7 +210,6 @@ def Shutdown(self):
# #20437 tracks consolidating these.
#
self._ChipStackLib.pychip_CommonStackShutdown()
self.networkLock = None
self.completeEvent = None
self._ChipStackLib = None
self._chipDLLPath = None
Expand All @@ -226,10 +223,7 @@ def Call(self, callFunct, timeoutMs: int = None):
This function is a wrapper of PostTaskOnChipThread, which includes some handling of application specific logics.
Calling this function on CHIP on CHIP mainloop thread will cause deadlock.
'''
# TODO: Lock probably no longer necessary, see https://github.com/project-chip/connectedhomeip/issues/33321.
with self.networkLock:
res = self.PostTaskOnChipThread(callFunct).Wait(timeoutMs)
return res
return self.PostTaskOnChipThread(callFunct).Wait(timeoutMs)

async def CallAsync(self, callFunct, timeoutMs: int = None):
'''Run a Python function on CHIP stack, and wait for the response.
Expand All @@ -256,9 +250,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()
res = self.PostTaskOnChipThread(callFunct).Wait()

if not res.is_success:
self.completeEvent.set()
Expand Down
Loading