Enabling long-running, external asyncio functionality #339
Unanswered
mindset-team
asked this question in
Q&A
Replies: 1 comment 4 replies
-
You may have a look at my solution for another, but IMHO related, problem here |
Beta Was this translation helpful? Give feedback.
4 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.
Uh oh!
There was an error while loading. Please reload this page.
-
Textual is considered as a front-end consuming events (e.g., using Redis' PUBSUB, full code will be posted as a Show&Tell after clearing issues below as this might be interesting to the community).
Below is generic code attempting a background asyncio task to run indefinitely while preserving all of Textual's functionality:
Running the app and immediately pressing the bound
esc
key terminates the program gracefully. Here's the log:However- a mouse click on the widget's body (which triggers a set_focus event) somehow locks further key functionality (i.e.
esc
doesn't work, view.forwarded Key doesn't fire as seen in the log below). Moreover,ctrl-c
must be used to terminate:This is clearly related to the long-running async functionality we're attempting to implement. Commenting out the
await self.async_functionality()
from the widget'son_mount
directive shows the expected behavior for Textual (mouse click works, down/up events trigger,esc
quit works):Any advise on how to implement this long-running async functionality while interacting with the TUI would be great.
[update: posted on stackoverflow]
Beta Was this translation helpful? Give feedback.
All reactions