Replies: 1 comment
-
We do have plans to introduce long running task management, as it is a common requirement. We also want to add a little syntactical sugar, possibly through a decorator. The underlaying API may look something like you have proposed... |
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.
Uh oh!
There was an error while loading. Please reload this page.
-
My proposal is to add methods for launching / getting / stopping aio.tasks via Textual app methods, instead of asyncio.create_task().
AIO tasks usage pattern is typically long-running procedure in the background, which may emit events, run processes or listen sockets.
Here are main issues I faced with handling Textual tasks:
When the task raised an unhandled exception, it's not propagated to the application. (It's an asyncio feature, but it would be great to raise a full app exception when a task fails). However, the exception message is printed in textual dev console, which is good. This issue leads to silenced bugs, when app still running, but background tasks are dead.
When the app is closed, the running task doesn't receive any notifications about the shutting down app.
Rationale
I believe it's common approach for the sake of having TUI responsive to launch long-running functions as an aio.tasks. All issues above can be resolved manually, however it would be nice to have shortcuts for task management in the Textual App.
Proposed API:
Obviously, the app under the hood should check if scheduled tasks are done, raise their unhandled exceptions, run callbacks, and cancel running tasks when the app is shutting down.
Let me know what are your thoughts on this.
Thanks
To be added by @willmcgugan
Beta Was this translation helpful? Give feedback.
All reactions