beeware / beeware/toga

Warn when the main loop is being blocked

Open
#2,633 1 comment 0 reactions 0 assignees View on GitHub
enhancement not quite right
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
15h 39m
Merged PRs (30d)
40

Description

### 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](https://docs.python.org/3/library/asyncio-dev.html#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.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing Python's asyncio debug mode and how Toga integrates with native event loops. Compare whether existing asyncio warnings meet the goal, then define a development-only warning for event-loop blocking that appears while the loop is blocked and is understandable to users.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.