Newly fired callbacks override older callbacks that are still running

Hey :slight_smile: ,

I have a CRUD dash datatable that executes sql queries against a mssql database.
Now, when an UPDATE callback is fired through a user interaction, an UPDATE query is being fired and the SQL table updates.

When the user updates a little bit faster, the older queries will not make it to being compiled and executed.
The newest query will be executed.

It takes between 0.5-2 seconds for my function to evaluate which, how many, and how to update rows,
Therefore any change that is faster then that, will cause newer callback to override older ones.

What works ? time.sleep(X)
I really dont want to use time.sleep(X). If a user perform 10-100-1000 changes that will fire the update callback, he will die before he can use the table.

Important Note, in my app, if a user changes more than 12 changes at once, a DELETE will be preformed on the rows, then a dataframe with the new changes will be appended to the table, so im covered that way.
The problem is when a single line is being updated, which could happen more then 12 times and all the rows will be UPDATED, not DELETED and appended.

I didnt find anything in the docs, how can i overcome this issue ?
Is there any built-in solution for this from dash ?
If not, anything i could achieve with pure python ?

I guess the easiest solution would be to add a spinner that blocks user inputs during the update. Would that be an option?

No because the user’s experience is a top priority and blocking each update is not realistic.

I didn’t find any other solution other than delaying each new update by an arbitrary amount of seconds (1.5s for example).

In that case, you should run the process async. Delaying the update by a fixed amout of seconds (e.g. 1.5s) is not a robust solution.