Replies: 1 comment 1 reply
-
The I think you will need to do something along these lines: future = await loop.run_in_executor(None, lambda: self.slow_func())
result = future.result() We are looking in to ways of simplifying concurrency with Textual, to hide such details. In the future we might have some kind of decorator to do this. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If some slow function is being called on button press like this:
both messages will not be shown until after
on_button_pressed()
has returned. Is there a clean way to update the UI before doing something slow?My current workaround is to do
which achieves the desired timing of updates, but any exceptions raised in
slow_func()
get swallowed, the UI just hangs instead of showing the backtrace. This makes development and debugging difficult. Also, of course the button state goes back to normal after the button press handler returns, which is not what I'd want in this case.Beta Was this translation helpful? Give feedback.
All reactions