Open rmartin16 opened 3 weeks ago
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.
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.