Respect write-locks in synchronous Websocket events #1170
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As described in #1148 we override the bokeh Websocket handlers asynchronous locking mechanisms to allow synchronous functions to trigger updates on the frontend immediately instead of blocking until they finish, e.g.:
If we didn't do this, this example wouldn't update the progress bar until the callback finishes. However in implementing this we are not respecting the Websocket handlers write lock. This PR ensures checks whether a write lock is enabled and if so locks the synchronous events out. This ensures most computations where updates aren't triggered in very quick succession can synchronously trigger events but may result in unexpected behavior where a callback suddenly locks in the middle. However once the callback finishes it'll all be made consistent so I think this is a worthwhile tradeoff until we handle async callbacks correctly.
Fixes #1148