From 7bb39ef75bc68e2a540f5dbd0d2432b814955122 Mon Sep 17 00:00:00 2001 From: Dave Pearson Date: Wed, 2 Nov 2022 14:35:21 +0000 Subject: [PATCH] Always clean up when coming out of the Pilot --- src/textual/app.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/textual/app.py b/src/textual/app.py index 577a66688..9659b399f 100644 --- a/src/textual/app.py +++ b/src/textual/app.py @@ -679,11 +679,12 @@ class App(Generic[ReturnType], DOMNode): app._set_active() # Context manager returns pilot object to manipulate the app - yield Pilot(app) - - # Shutdown the app cleanly - await app._shutdown() - await app_task + try: + yield Pilot(app) + finally: + # Shutdown the app cleanly + await app._shutdown() + await app_task async def run_async( self,