Skip to content

Commit fb630f1

Browse files
committed
fix: Address race condition and dependency compatibility issues
- Fix race condition between BLEInterface.close() and _on_ble_disconnect() by checking self._closing flag to prevent concurrent BLEClient.close() calls - Pin protobuf to ^4.25.3 and types-protobuf to ^4.25.3 for compatibility - Prevent RuntimeError from concurrent access to BLEClient event loop - Ensure close() has exclusive control over shutdown process once initiated Critical fixes that prevent installation failures and runtime race conditions during BLE interface disconnection scenarios.
1 parent 342037c commit fb630f1

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

meshtastic/ble_interface.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ def __repr__(self):
108108

109109
def _on_ble_disconnect(self, client) -> None:
110110
"""Disconnected callback from Bleak."""
111+
if self._closing:
112+
logger.debug("Ignoring disconnect callback because a shutdown is already in progress.")
113+
return
114+
111115
address = getattr(client, "address", repr(client))
112116
logger.debug(f"BLE client {address} disconnected.")
113117
if self.auto_reconnect:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ readme = "README.md"
99
[tool.poetry.dependencies]
1010
python = "^3.9,<3.14" # 3.9 is needed for pandas, bleak requires <3.14
1111
pyserial = "^3.5"
12-
protobuf = ">=4.21.12"
12+
protobuf = "^4.25.3"
1313
tabulate = "^0.9.0"
1414
requests = "^2.31.0"
1515
pyyaml = "^6.0.1"
@@ -37,7 +37,7 @@ pylint = "^3.2.3"
3737
pyinstaller = "^6.8.0"
3838
mypy = "^1.10.0"
3939
mypy-protobuf = "^3.3.0"
40-
types-protobuf = "^5.26.0.20240422"
40+
types-protobuf = "^4.25.3"
4141
types-tabulate = "^0.9.0.20240106"
4242
types-requests = "^2.31.0.20240406"
4343
types-setuptools = "^69.5.0.20240423"

0 commit comments

Comments
 (0)