This fixes a race condition when the prompt_toolkit Application gets cancelled while waiting for the background tasks to complete. Catching CancelledError at this point caused any code following the Application.run_async to continue, instead of being cancelled.
In the future, we should probably adapt task groups (from anyio or Python 3.11), but until then, this is sufficient.
This fixes a race condition when the prompt_toolkit Application gets cancelled while waiting for the background tasks to complete. Catching
CancelledError
at this point caused any code following theApplication.run_async
to continue, instead of being cancelled.In the future, we should probably adapt task groups (from anyio or Python 3.11), but until then, this is sufficient.