Skip to content

Commit e7743d3

Browse files
committed
fix for freeze issue
1 parent 91927a4 commit e7743d3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/textual/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,15 +2011,15 @@ async def _prune_node(self, root: Widget) -> None:
20112011
for children in reversed(node_children):
20122012
# Closing children can be done asynchronously.
20132013
close_messages = [
2014-
child._close_messages() for child in children if child._running
2014+
child._close_messages(wait=True) for child in children if child._running
20152015
]
20162016
# TODO: What if a message pump refuses to exit?
20172017
if close_messages:
20182018
await asyncio.gather(*close_messages)
20192019
for child in children:
20202020
self._unregister(child)
20212021

2022-
await root._close_messages()
2022+
await root._close_messages(wait=False)
20232023
self._unregister(root)
20242024

20252025
async def action_check_bindings(self, key: str) -> None:

src/textual/message_pump.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def _close_messages_no_wait(self) -> None:
284284
async def _on_close_messages(self, message: messages.CloseMessages) -> None:
285285
await self._close_messages()
286286

287-
async def _close_messages(self) -> None:
287+
async def _close_messages(self, wait: bool = True) -> None:
288288
"""Close message queue, and optionally wait for queue to finish processing."""
289289
if self._closed or self._closing:
290290
return
@@ -296,7 +296,7 @@ async def _close_messages(self) -> None:
296296
await self._message_queue.put(events.Unmount(sender=self))
297297
Reactive._reset_object(self)
298298
await self._message_queue.put(None)
299-
if self._task is not None and asyncio.current_task() != self._task:
299+
if wait and self._task is not None and asyncio.current_task() != self._task:
300300
# Ensure everything is closed before returning
301301
await self._task
302302

0 commit comments

Comments
 (0)