-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow_duplicate on outputs doesn't work #475
Comments
This is essentially the statement that Are you in a position to make your callback structure less ill-defined and consolidate the calculations so that only one callback is used for an output value? If the multiple callbacks are non-trivial to combine you could insert a dummy hidden output for each callback (add in also a timestamp or similar if you need to work out which one to use) and then add a third callback to determine which is to be used. Given that multiple callbacks implicitly say 'use whatever arrived the most recently, dont care what that is' then at worst this introduces the overhead of a third callback (which one could make run locally in the browser if an issue) but also permits the question of which value to be used to be directly addressed. |
I would also like to use For what it's worth, the race condition described by @delsim does not necessarily arise if @delsim any chance this argument will be supported in Thank you so much for any response on this! |
Ah @delsim sorry for my confusion, I found that @zyassine perhaps that answers your question? |
Whoops - @delsim I notice @zyassine perhaps this is what you referred to originally. |
@delsim I am noticing the same thing that @zyassine and @zachsiegel-capsida are seeing and would love the Any more updates on this functionality? Personally would be using it because I have a bunch of input elements that correspond to local session storage items and would want a change to any of the inputs to update the session storage that it corresponds to. Therefore, I want multiple callbacks pointing to update the same session storage object. |
@zachsiegel-capsida I'm struggling to see how Whilst this issue might not manifest on a single-threaded synchronous server such as the test ones in Django, Flask etc., as these will only process the callbacks in order, it will nevertheless become quite apparent as soon as one moves to a production environment and uses multiple threads or processes or an async server; there is no guarantee of the order in which the callbacks will return their value to the server. There is a note to this effect in the dash documentation. @ryan-bloom what stops you having each callback update a separate value and then combine all of these values into the session object with an additional callback? Or, if the purpose of the session object is to maintain some server-side composite record, make updating it a side-effect of a callback rather than its return value. |
@delsim I totally see your point! Thanks so much for this response. I do stand by my comment below, though:
You're taking issue with my claim that only "pathological patterns" cause race conditions and I see your point, but it is possible to avoid them to an acceptable level in practice and that's why Dash supports Enforcing this pattern in django-plotly-dash when Dash no longer enforces it is probably not what most people expect from this (excellent!) package. I think most people want/expect a wrapper that lets them use Dash from Django, and the more the django-plotly-dash interface deviates from Dash the more difficult that will be (and the more documentation dpd requires to clarify those differences). As always thank you for maintaining this package and for responding thoughtfully to GitHub issues! |
I have a dash app where I update the Output in many Dash Callbacks. In order to do it, I have to use
allow_duplicate=True
in the Output argument, but it doesn't work on a django dash app.This is a basic Dash app to showcase the use of
allow_duplicate
:If I use
app = DjangoDash(__name__)
, then the output doesn't get updatedThe text was updated successfully, but these errors were encountered: