Skip to content
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

Issue 1010 - Non-rendered async components using asyncDecorator lock renderer callbacks #1027

Merged
merged 14 commits into from
Nov 26, 2019

Conversation

Marc-Andre-Rivet
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Nov 22, 2019

Fixes #1010

It is possible for a component in the layout not to be displayed (e.g. tabs) and as such, async resources associated with it will not be loaded. If the component uses the asyncDecorator this means that the component could block the renderer's callbacks indefinitely.

This change reduces the scope of the renderer's callback lock by only using the components required as input/state to determine the required lock.

A new test has been added and demonstrated to fail prior to adding the fix (f5e577e)


return promises.length ? Promise.all(promises) : true;
return promises.length ? Promise.all(promises) : true;
};
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change isAppReady to return either the global state of the app or the state for the target ids given.

if n_clicks is None:
raise PreventUpdate

return "Bye"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the changes in this PR, this callback is never triggered because of the blocking dash-table (uses the asyncDecorator) in the other tab. Now, since the callback only involves btn and output, the table is non-blocking.

@Marc-Andre-Rivet Marc-Andre-Rivet changed the title [WIP] Issue 1010 - Not-loaded async component with isReady decorator prevents callbacks from executing Issue 1010 - Not-loaded async component with isReady decorator prevents callbacks from executing Nov 23, 2019
@Marc-Andre-Rivet Marc-Andre-Rivet marked this pull request as ready for review November 23, 2019 14:28
@Marc-Andre-Rivet Marc-Andre-Rivet changed the title Issue 1010 - Not-loaded async component with isReady decorator prevents callbacks from executing Issue 1010 - Non-rendered async components using asyncDecorator lock renderer callbacks Nov 23, 2019
components[namespace][type] = type;
const isAppReady = (layout, paths) => targets => {
if (!layout || !paths || !Array.isArray(targets)) {
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a use case for this? Feels like an error rather than a silent success.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relates to the comment below. Refactoring to take isAppReady outside of the state, timing issues will be moot.


components[namespace] = components[namespace] || {};
components[namespace][type] = type;
const isAppReady = (layout, paths) => targets => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as we get the order of operations right (ie always updating isAppReady after any update to layout or paths) this should be fine, but it would be more robust and simpler - without any cost anymore - to not put this in the state at all.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ie to just make it a function (layout, paths, targets) => {...}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly the problem making the tests fail, the store evals IS_APP_READY before COMPUTE_PATH and the first calls ends up not blocking

}

graph_2_expected_clickdata = {
"points": [{"curveNumber": 0, "pointNumber": 1, "pointIndex": 1, "x": 3, "y": 10}]
"points": [{"curveNumber": 0, "pointNumber": 1, "pointIndex": 1, "x": 3, "y": 10, "label": 3, "value": 10}]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexcjohnson Getting the same error you have in #1026 -- there seems to be additional label/value props

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added #1031 for follow up

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a beautiful thing when - even with new tests - a bug fix results in the codebase shrinking 🎉 💪 💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Dash 1.6 Datatable disables all callbacks if not in initial layout
2 participants