fix: yield event loop after automatic UI updates - #6764
Conversation
Synchronous generator event handlers use `yield` as an explicit boundary for intermediate UI updates. Although auto-update queued the corresponding UI patch, `__auto_update()` did not actually suspend execution. The generator could therefore resume immediately, allowing blocking work such as `time.sleep()` to prevent the send loop from processing the queued update. Return whether `__auto_update()` updated a control and yield control to the event loop when it did. This ensures the send loop gets an opportunity to dispatch the UI patch before the handler continues, preserving the expected intermediate update behavior of `yield` and refreshing the UI after handler auto-updates.
|
Thanks for the PR! The diagnosis is correct and the mechanism works. I checked out the branch and reproduced the behavior with a harness that mimics the socket transport ( One A few things before this can be merged. 1. Lint fails
if (
context.auto_update_enabled()
and not context.was_update_called()
and await self.__auto_update(control)
):
# give the send loop a chance to flush the patch before the
# handler resumes and possibly blocks
await asyncio.sleep(0)2. The fix misses explicit
|
Description
Synchronous generator event handlers use
yieldas an explicit boundary for intermediate UI updates. Although auto-update queued the corresponding UI patch,__auto_update()did not actually suspend execution.The generator could therefore resume immediately, allowing blocking work such as
time.sleep()to prevent the send loop from processing the queued update.Return whether
__auto_update()updated a control and yield control to the event loop when it did. This ensures the send loop gets an opportunity to dispatch the UI patch before the handler continues, preserving the expected intermediate update behavior ofyieldand refreshing the UI after handler auto-updates.Test code
# Minimal test/reproduction code for reviewers, if applicable.Type of change
Checklist
website/sidebars.ymlfor breaking changes, removals, and deprecations, if applicable.Screenshots
Additional details
Summary by Sourcery
Ensure automatic UI updates triggered after event handlers yield control to the event loop so queued patches are sent before the handler continues.
Bug Fixes:
Enhancements: