mirror of
https://github.com/kawasaki/pyscrlink.git
synced 2025-07-21 09:31:21 +02:00
BLESession: Close session on Exception
When an exception is thrown during a session, still the session no longer works, but still keeps connection. With this status, following device scan can not find the device. This symptom was observed when micro:bit with scratch-microbit.hex is connected to "micro:bit MORE" and BTLEException is thrown. Another symptom observed is the Scratch web page closed and websocket connection slows ConnectionClosedOK exception. To avoid the device scan failure, close the session when an exception is caught. Also improve error message for the exception. Signed-off-by: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
This commit is contained in:
@@ -669,7 +669,8 @@ async def ws_handler(websocket, path):
|
||||
await session.handle()
|
||||
except Exception as e:
|
||||
logger.error(f"Failure in session for web socket path: {path}")
|
||||
logger.error(e)
|
||||
logger.error(f"{type(e).__name__}: {e}")
|
||||
session.close()
|
||||
|
||||
def stack_trace():
|
||||
print("in stack_trace")
|
||||
|
Reference in New Issue
Block a user