Ensuring app_service variable is bound in finally block

This commit is contained in:
Darren Burns
2024-08-06 13:40:10 +01:00
parent ce46e6b78e
commit ef8685471c
3 changed files with 5 additions and 3 deletions

View File

@@ -67,7 +67,7 @@ rich==13.7.1
sniffio==1.3.1
# via anyio
# via httpx
textual==0.74.0
textual==0.75.1
# via textual-serve
typing-extensions==4.12.2
# via anyio

View File

@@ -50,7 +50,7 @@ pygments==2.18.0
rich==13.7.1
# via textual
# via textual-serve
textual==0.74.0
textual==0.75.1
# via textual-serve
typing-extensions==4.12.2
# via rich

View File

@@ -274,6 +274,7 @@ class Server:
width = to_int(request.query.get("width", "80"), 80)
height = to_int(request.query.get("height", "24"), 24)
app_service: AppService | None = None
try:
await websocket.prepare(request)
app_service = AppService(
@@ -296,6 +297,7 @@ class Server:
log.exception(error)
finally:
await app_service.stop()
if app_service is not None:
await app_service.stop()
return websocket