Closed vishnu-rvb closed 1 day ago
Please provide some runnable code which reproduces the issue.
Im getting the same issue
Im getting the same issue
Saying it like this doesnt help at all. Provide some runnable code to test the issue.
@vishnu-rvb
Please share the entire code so we can fully examine the issue.
Fixed the issue. What I ended up doing is locking the threads right before creating/modifying the UI (this involves creating elements, updating the page, etc.) and then unlocking them right after.
I believe the issue arose from a race condition involving the state of the page where certain threads were updating different versions of the same page.
I order to fix your specific issue go ahead and lock and unlock the threads before in after updating the page in the page function, like this:
import Threading
lock = Threading.lock
...
def updatePage(self,dt,page: Page):
lock.aquire()
page.update()
lock.release()
If that doesn't work maybe try adding it to your RefreshItems function as well.
@ethans333 yeah i too fixed my issue by disabling page update when controls are added but concern wise it should be page.updates responsibility to sort out its internal race conditions.
@ndonkoHenri i will share a demo reproducing code for future references soon
Agreed
Duplicate Check
Describe the bug
i am using threading to call page.update() periodically at a set time from a new thread. I also have a button called refresh that changes modifies page controls. sometimes it is seen that page.update() is raising an error which i am not sure why and why its only sometimes and not all times. i am sharing the relevant segments of the code.
Code
To reproduce
1)Initial state: 2)Clicking Refresh button multiple times 3)When error is raised:
Expected behavior
Expected RefreshItems function call to be completed but is terminated due to the raised error
Screenshots
Error seen
Operating System
Windows
Operating system details
Windows 10
Flet version
Name: flet Version: 0.23.2 Summary: Flet for Python - easily build interactive multi-platform apps in Python Home-page: https://flet.dev Author: Appveyor Systems Inc. Author-email: hello@flet.dev License: Apache-2.0 Location: c:\program files\python310\lib\site-packages Requires: cookiecutter, fastapi, flet-runtime, packaging, qrcode, uvicorn, watchdog Required-by:
Regression
No, it isn't
Suggestions
Seems like page update is hindered when refresh is in the process of modifying flet controls. would prefer if update checks and waits for end of refresh function call
Additional details
No response