mirror of
https://github.com/kawasaki/pyscrlink.git
synced 2025-09-05 17:20:20 +02:00
BLESession.close: Improve close handler
Guard peripheral disconnect handling with lock not to race with other peripheral operations. After disconnect, set None to the peripheral reference to ensure no use.
This commit is contained in:
@@ -433,7 +433,9 @@ class BLESession(Session):
|
|||||||
self.status = self.DONE
|
self.status = self.DONE
|
||||||
if self.perip:
|
if self.perip:
|
||||||
logger.info(f"disconnect to BLE peripheral: {self.perip}")
|
logger.info(f"disconnect to BLE peripheral: {self.perip}")
|
||||||
self.perip.disconnect()
|
with self.lock:
|
||||||
|
self.perip.disconnect()
|
||||||
|
self.perip = None
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.close()
|
self.close()
|
||||||
|
Reference in New Issue
Block a user