Skip to content

Commit 88ebdf7

Browse files
authored
[Python] Remove Python Bluetooth and ChipStack event loop integration (project-chip#33775)
The Python Bluetooth implementation for Linux (`BluezManager` in ChipBluezMgr.py) and macOS (`CoreBluetoothManager` in ChipCoreBluetoothMgr.py) integrate with ChipStack to pump their event loops on long running operations such as commissioning (through `CallAsyncWithCompleteCallback()`). From what I can tell, the Python Bluetooth stack is only used for some mbed integration tests. Specifically through `scan_chip_ble_devices()` in src/test_driver/mbed/integration_tests/common/utils.py. This operation doesn't need the event loop integration. So as a first step, this PR simply breaks this tie and removes the event loop integration with the Device ChipStack/ChipDeviceController.
1 parent d15f6c1 commit 88ebdf7

File tree

4 files changed

+1
-15
lines changed

4 files changed

+1
-15
lines changed

src/controller/python/chip/ChipBluezMgr.py

-1
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,6 @@ def __init__(self, devMgr, logger=None):
807807
self.rx = None
808808
self.setInputHook(self.readlineCB)
809809
self.devMgr = devMgr
810-
self.devMgr.SetBlockingCB(self.devMgrCB)
811810

812811
def __del__(self):
813812
self.disconnect()

src/controller/python/chip/ChipCoreBluetoothMgr.py

-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ def __init__(self, devCtrl, logger=None):
184184
def __del__(self):
185185
self.disconnect()
186186
self.setInputHook(self.orig_input_hook)
187-
self.devCtrl.SetBlockingCB(None)
188-
self.devCtrl.SetBleEventCB(None)
189187

190188
def devMgrCB(self):
191189
"""A callback used by ChipDeviceCtrl.py to drive the OSX runloop while the

src/controller/python/chip/ChipDeviceCtrl.py

-5
Original file line numberDiff line numberDiff line change
@@ -1591,11 +1591,6 @@ async def ReadEvent(self, nodeid: int, events: typing.List[typing.Union[
15911591
else:
15921592
return res.events
15931593

1594-
def SetBlockingCB(self, blockingCB):
1595-
self.CheckIsActive()
1596-
1597-
self._ChipStack.blockingCB = blockingCB
1598-
15991594
def SetIpk(self, ipk: bytes):
16001595
self._ChipStack.Call(
16011596
lambda: self._dmLib.pychip_DeviceController_SetIpk(self.devCtrl, ipk, len(ipk))

src/controller/python/chip/ChipStack.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ def HandleChipThreadRun(callback):
165165
callback()
166166

167167
self.cbHandleChipThreadRun = HandleChipThreadRun
168-
# set by other modules(BLE) that require service by thread while thread blocks.
169-
self.blockingCB = None
170168

171169
#
172170
# Storage has to be initialized BEFORE initializing the stack, since the latter
@@ -255,11 +253,7 @@ def CallAsyncWithCompleteCallback(self, callFunct):
255253
if not res.is_success:
256254
self.completeEvent.set()
257255
raise res.to_exception()
258-
while not self.completeEvent.isSet():
259-
if self.blockingCB:
260-
self.blockingCB()
261-
262-
self.completeEvent.wait(0.05)
256+
self.completeEvent.wait()
263257
if isinstance(self.callbackRes, ChipStackException):
264258
raise self.callbackRes
265259
return self.callbackRes

0 commit comments

Comments
 (0)