question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling `update()` inside `Control.did_mount()` causes deadlock

See original GitHub issue

Sample code causing deadlock:

import flet
from flet import Container, Page, Text, UserControl

class MyControl(UserControl):
    def build(self):
        print("i am built")
        self.c = Container()
        self.c.bgcolor = "blue"
        self.c.content = Text("hello there")
        return self.c

    def did_mount(self):
        print("i am mounted")
        self.resize_me()

    def resize_me(self):
        self.c.bgcolor = "red"
        self.update()

def main(page: Page):
    t = MyControl()
    page.add(t)
    print("i am added")

flet.app(target=main)

Solution:

Go through a list of added controls after update() is finished and lock released and call did_mount() for each added control.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
FeodorFitsnercommented, Nov 11, 2022

Sure, it’s possible now.

0reactions
ItsCubeTimecommented, Dec 16, 2022

Ah I see

Thank you for clarifying

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting deadlock when execute UPDATE at same time
I'm load testing the application and get deadlock error. The scenario is inserting and updating database concurrently by 10 different users. I ...
Read more >
Deadlock occurs when issuing SELECT and UPDATE ...
I'm using SQL Server 2019, but a deadlock occurs when there is a lot of access. The target SELECT statement refers to only...
Read more >
Process getting deadlock while updating a table in parallel
We are calling an update statement from Abinitio to oracle DB. Statement is running in parallel(4) with default table values(INI_RANS=1, ...
Read more >
Why am I getting a deadlock for a single UPDATE query?
Your statement modifies several rows. Each of these rows is locked when it is updated. It is well possible that a statement in...
Read more >
A Simple Explanation of React.useEffect() - Dmitri Pavlutin
Especially useEffect() — the hook that manages side-effects in functional React ... 3.1 Component did mount; 3.2 Component did update.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found