Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed May 30, 2024
1 parent f663bca commit b203326
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3362,8 +3362,6 @@ async def _prune_nodes(self, widgets: list[Widget]) -> None:
Args:
widgets: Widgets to remove.
"""
if not self.is_attached:
return
async with self._dom_lock:
for widget in widgets:
await self._prune_node(widget)
Expand All @@ -3375,6 +3373,7 @@ async def _prune_node(self, root: Widget) -> None:
root: Node to remove.
"""
# Pruning a node that has been removed is a no-op

if root not in self._registry:
return

Expand Down
10 changes: 6 additions & 4 deletions src/textual/message_pump.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ def app(self) -> "App[object]":
@property
def is_attached(self) -> bool:
"""Is this node linked to the app through the DOM?"""
if self.is_dom_root:
return True
node: MessagePump | None = self

while (node := node._parent) is not None:
if node.is_dom_root:
return True
Expand Down Expand Up @@ -479,9 +480,10 @@ async def _close_messages(self, wait: bool = True) -> None:
if self._closed or self._closing:
return
self._closing = True
stop_timers = list(self._timers)
for timer in stop_timers:
timer.stop()
await Timer._stop_all(self._timers)
# stop_timers = list(self._timers)
# for timer in stop_timers:
# timer.stop()
self._timers.clear()
await self._message_queue.put(events.Unmount())
Reactive._reset_object(self)
Expand Down
2 changes: 1 addition & 1 deletion src/textual/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def publish(self, data: SignalT) -> None:
"""

for node, callbacks in list(self._subscriptions.items()):
if not node.is_running:
if not (node.is_running and node.is_attached):
# Removed nodes that are no longer running
self._subscriptions.pop(node)
else:
Expand Down

0 comments on commit b203326

Please sign in to comment.