Textualize / textual

The lean application framework for Python. Build sophisticated user interfaces with a simple Python API. Run your apps in the terminal and a web browser.
https://textual.textualize.io/
MIT License
24.07k stars 741 forks source link

Fix deadlock between node removal and closing the app #4679

Closed slawek-es closed 4 days ago

slawek-es commented 6 days ago

There is a deadlock issue on App._dom_lock, where _close_all holds the lock and waits for the task associated with a message pump, but that task may be executing a "called-next" _prune_nodes call driven by an AwaitRemove which was triggered, for example, by the Footer.recompose call from handling the bindings_updated signal. This deadlock leads to a TimeoutError on app close.

We fix this by omitting the call to _prune_nodes in the AwaitRemove task if the whole application is already closing; it does not make sense to remove individual nodes in this case anyway.

Fixes #4677

Please review the following checklist.

willmcgugan commented 5 days ago

This will prevent Unmount messages from being sent.