You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If processing messages take longer than a fraction of a second, it can cause the UI to freeze.
This is usually the result blocking operations or cpu intensive work in a message handler. The solution is typically to do the work in a worker, but devs may not know to do that.
Given its a gotcha, I think Textual can do a little more to help.
I think what we should do is time how long a message has taken to process. If it is longer than, say 500ms, it should log a warning.
This should only be enabled in debug mode. The maximum time should be set in an environment variable.
Display warning for message handers that take a long time
Enable in debug mode
Add env var to set the time that produces a warning
Should not add to much cpu work to message processing
Bonus points
Strictly following the above, would not produce a warning until the handler returns. If it takes 30 seconds, the dev would not see anything.
It would be great if long running message handlers produce a warning even before the handler returns. This would be a little trickier to implement. And it should be done in a way that doesn't slow down non-debug runs.
The text was updated successfully, but these errors were encountered:
If processing messages take longer than a fraction of a second, it can cause the UI to freeze.
This is usually the result blocking operations or cpu intensive work in a message handler. The solution is typically to do the work in a worker, but devs may not know to do that.
Given its a gotcha, I think Textual can do a little more to help.
I think what we should do is time how long a message has taken to process. If it is longer than, say 500ms, it should log a warning.
This should only be enabled in debug mode. The maximum time should be set in an environment variable.
I suspect, the best place to do this would be https://github.com/Textualize/textual/blob/main/src/textual/message_pump.py#L637
Requirements:
Bonus points
Strictly following the above, would not produce a warning until the handler returns. If it takes 30 seconds, the dev would not see anything.
It would be great if long running message handlers produce a warning even before the handler returns. This would be a little trickier to implement. And it should be done in a way that doesn't slow down non-debug runs.
The text was updated successfully, but these errors were encountered: