FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix BLE close() deadlock from re-entrant disconnect callback · meshtastic/python@1ee4710 · GitHub

Commit 1ee4710

Browse files
andcommitted
Fix BLE close() deadlock from re-entrant disconnect callback
When close() disconnects the BLE device, Bleak fires the disconnected_callback which calls close() again. The second close() tries to disconnect while the first is still in progress, causing a deadlock. Add a _closing guard flag to prevent the re-entrant call. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0539a96 commit 1ee4710

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎meshtastic/ble_interface.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__( # pylint: disable=R0917
5656
)
5757

5858
self.should_read = False
59+
self._closing = False
5960

6061
logger.debug("Threads starting")
6162
self._want_receive = True
@@ -250,6 +251,10 @@ def _sendToRadioImpl(self, toRadio) -> None:
250251
self.should_read = True
251252

252253
def close(self) -> None:
254+
if self._closing:
255+
return
256+
self._closing = True
257+
253258
try:
254259
MeshInterface.close(self)
255260
except Exception as e:

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL