-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible dev tools and threads issue #4060
Comments
I've noticed this when moving a lot of data through workers and messages. Kind of related to #2588 because the default output to console can end up calling repr on and then printing some very large objects, which noticeably slows things down. This app runs in 0.4 s without the console ( from __future__ import annotations
from textual._path import CSSPathType
from textual.app import App, CSSPathType, ComposeResult
from textual.driver import Driver
from textual.widgets import Static
import time
from textual import work, on
from textual.message import Message
class SlowConsole(App):
class Result(Message):
def __init__(self, len: int) -> None:
self.len = len
super().__init__()
def __init__(
self,
driver_class: type[Driver] | None = None,
css_path: CSSPathType | None = None,
watch_css: bool = False,
):
self.data = [(i, "one", "two", "three", "four") for i in range(1_000_000)]
self.start = time.monotonic()
super().__init__(driver_class, css_path, watch_css)
def compose(self) -> ComposeResult:
self.static = Static("working")
yield self.static
def on_mount(self) -> None:
self.check_data(self.data)
@work(thread=True)
def check_data(self, data: list) -> None:
self.post_message(self.Result(len(data)))
@on(Result)
def update_static(self, message: Result) -> None:
self.static.update(f"{message.len} {time.monotonic() - self.start}")
SlowConsole().run() |
We've decided to park this for now after thinking about alternative approaches. We couldn't think of anything that we can do that wouldn't massively interfere with how useful the devtools are in general. |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
While debugging Tailless, I often find the app gets stuck, but only when running devtools.
I suspect there is some interaction with threads and devtools here.
If any one picks this up, please try first to reproduce with an MRE. I may be wrong.
Update: I suspect what I'm seeing is just because I am writing very large print statements. It may not be a threading issue per se.
The text was updated successfully, but these errors were encountered: