Skip to content
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

Warn when the main loop is being blocked #2633

Open
rmartin16 opened this issue Jun 10, 2024 · 1 comment
Open

Warn when the main loop is being blocked #2633

rmartin16 opened this issue Jun 10, 2024 · 1 comment
Labels
enhancement New features, or improvements to existing features. not quite right The idea or PR has been reviewed, but more work is needed.

Comments

@rmartin16
Copy link
Member

rmartin16 commented Jun 10, 2024

What is the problem or limitation you are having?

Users that don't understand the consequences of blocking the main loop may be surprised when their app seems to freeze. If, however, Toga could drop a warning this is happening once the loop has been blocked for more than X seconds, the issue may become more apparent. Moreover, this may also help aware users detect when they unintentionally block the loop for too long.

Describe the solution you'd like

Detect long running tasks on the event loop and print a warning for users.

Ideally, the warning would occur while the event loop is being blocked but also only while the app is under development.

Describe alternatives you've considered

asyncio supports a debug mode that warns about long running tasks (among other things); although, it does so after the fact but nonetheless. That said and IMHO, some of asyncio's warnings are a little jargon heavy and may not have the intended effect for all users.

It could even be a good idea to ensure this debug mode is enabled by default irrespective of the implementation of this request.

Additional context

This idea is half-baked but based on interactions with users. Further, I'm anticipating some of the integrations with the native event loops to complicate any implementation of this.

@rmartin16 rmartin16 added the enhancement New features, or improvements to existing features. label Jun 10, 2024
@freakboy3742 freakboy3742 added the not quite right The idea or PR has been reviewed, but more work is needed. label Jun 10, 2024
@freakboy3742
Copy link
Member

Completely agreed that it would be nice to be able to warn the user about this sort of thing. However, outside a secondary monitoring thread, or an "after the fact" warning like debug mode, I'm not sure what that would look like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features. not quite right The idea or PR has been reviewed, but more work is needed.
Projects
None yet
Development

No branches or pull requests

2 participants