Replies: 1 comment
-
|
Recomposing will remove all children and mount new widgets. Your trigger action is getting a vertical, that has not yet completed mounting. You might want to elaborate on what problem you are attempting to solve with concurrency here. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Similar to #4570.
Reproduce: using the following code and press the "t" key repeatedly.
exception:
Details
``` $ textual run --dev mount_bug_reproduce.py ╭────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────╮ │ /home/comzyh/.virtualenvs/textual/lib/python3.11/site-packages/textual/widget.py:3735 in _compose │ │ │ │ 3732 │ │ │ self.app._handle_exception(error) │ │ 3733 │ │ else: │ │ 3734 │ │ │ self._extend_compose(widgets) │ │ ❱ 3735 │ │ │ await self.mount_composed_widgets(widgets) │ │ 3736 │ │ │ 3737 │ async def mount_composed_widgets(self, widgets: list[Widget]) -> None: │ │ 3738 │ │ """Called by Textual to mount widgets after compose. │ │ │ │ ╭────────────────────────────────────── locals ──────────────────────────────────────╮ │ │ │ self = Vertical() │ │ │ │ widgets = [Label(), Label(), Label(), Label(), Label(), Label(), Label(), Label()] │ │ │ ╰────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/comzyh/.virtualenvs/textual/lib/python3.11/site-packages/textual/widget.py:3748 in mount_composed_widgets │ │ │ │ 3745 │ │ │ widgets: A list of child widgets. │ │ 3746 │ │ """ │ │ 3747 │ │ if widgets: │ │ ❱ 3748 │ │ │ await self.mount_all(widgets) │ │ 3749 │ │ │ 3750 │ def _extend_compose(self, widgets: list[Widget]) -> None: │ │ 3751 │ │ """Hook to extend composed widgets. │ │ │ │ ╭────────────────────────────────────── locals ──────────────────────────────────────╮ │ │ │ self = Vertical() │ │ │ │ widgets = [Label(), Label(), Label(), Label(), Label(), Label(), Label(), Label()] │ │ │ ╰────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/comzyh/.virtualenvs/textual/lib/python3.11/site-packages/textual/widget.py:1016 in mount_all │ │ │ │ 1013 │ │ """ │ │ 1014 │ │ if self.app._exit: │ │ 1015 │ │ │ return AwaitMount(self, []) │ │ ❱ 1016 │ │ await_mount = self.mount(*widgets, before=before, after=after) │ │ 1017 │ │ return await_mount │ │ 1018 │ │ │ 1019 │ if TYPE_CHECKING: │ │ │ │ ╭────────────────────────────────────── locals ──────────────────────────────────────╮ │ │ │ after = None │ │ │ │ before = None │ │ │ │ self = Vertical() │ │ │ │ widgets = [Label(), Label(), Label(), Label(), Label(), Label(), Label(), Label()] │ │ │ ╰────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/comzyh/.virtualenvs/textual/lib/python3.11/site-packages/textual/widget.py:947 in mount │ │ │ │ 944 │ │ if self._closing: │ │ 945 │ │ │ return AwaitMount(self, []) │ │ 946 │ │ if not self.is_attached: │ │ ❱ 947 │ │ │ raise MountError(f"Can't mount widget(s) before {self!r} is mounted") │ │ 948 │ │ # Check for duplicate IDs in the incoming widgets │ │ 949 │ │ ids_to_mount = [ │ │ 950 │ │ │ widget_id for widget in widgets if (widget_id := widget.id) is not None │ │ │ │ ╭────────────────────────────────────── locals ──────────────────────────────────────╮ │ │ │ after = None │ │ │ │ before = None │ │ │ │ self = Vertical() │ │ │ │ widgets = (Label(), Label(), Label(), Label(), Label(), Label(), Label(), Label()) │ │ │ ╰────────────────────────────────────────────────────────────────────────────────────╯ │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ MountError: Can't mount widget(s) before Vertical() is mountedIn my environment, it only reproduces if I use reactive recompose.
If I remove the reactive add and uncomment 2 lines in
add_widgets,it won't happen.
Textual diagnose
Beta Was this translation helpful? Give feedback.
All reactions