Repository navigation
Conversation
Control property changes and reactive Component state from a worker are scheduled on the loop, but explicit update() sends its patch synchronously on the calling thread. Document the distinction and show marshalling the call back via page.run_task(). Follow-up to flet-dev#7107.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #7107. As offered in that thread, this adds a short paragraph to the Threading section of the Async apps guide.
What this clarifies
There are two distinct paths for pushing control changes to the client, and the guide currently documents neither:
Session.schedule_update()was made thread-safe in fix: make Session.schedule_update() and schedule_effect() thread-safe #7113 (call_soon_threadsafe()), and its source now explicitly states it is safe to call from any thread. Reactiveset_state()changes are marshalled to the loop as well.Control.update()call is different: it callsSession.patch_control()synchronously on the calling thread, and that path sends the patch without taking__updates_lock(the lock insession.pyguards the queue and session flags only). Calling it from a worker thread can interleave patches with the loop thread.The paragraph states the contract — call
update()from the event-loop thread — and shows how a worker can marshal the call back withpage.run_task().Scope
Documentation only, 19 added lines. No framework behaviour is changed. The example passes the coroutine function to
run_task()(not a called coroutine), matching the existing guidance in the Background tasks section.I raised #7107 after tracing
patch_control()on 0.86.5 and checking the equivalent path onmain; the scheduler path is now fixed, but the explicitupdate()path remains unchanged, so the documentation gap is still open. Happy to adjust the wording if maintainers prefer a different phrasing or placement.Summary by Sourcery
Documentation: