Skip to content

Commit f1b64e2

Browse files
committed
cli.lwp3.repl: fix crash on macOS
This works around a bug in bleak.
1 parent bbc048d commit f1b64e2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pybricksdev/cli/lwp3/repl.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,15 @@ def callback(dev: BLEDevice, adv: AdvertisementData) -> None:
9999

100100
queue.put_nowait(dev)
101101

102-
async with BleakScanner(detection_callback=callback):
102+
async with BleakScanner(detection_callback=callback) as scanner:
103103
logger.info("scanning...")
104104
device = await queue.get()
105+
106+
# monkey patch for bleak bug
107+
# https://github.com/hbldh/bleak/pull/534
108+
if hasattr(scanner, "_manager"):
109+
device.metadata["delegate"] = scanner._manager.central_manager.delegate()
110+
105111
logger.info("found device")
106112

107113
def handle_disconnect(client: BleakClient):

0 commit comments

Comments
 (0)