Viewing LOD status in python

Hi,
I’m working with massive data sets, so my data needs to be cut down significantly in python before the data is sent to the browser. As such, when the user zooms in, I need to send through a new block of data, calculating which might take up to about half a second.

Currently if someone zooms in with the mousewheel, this then runs the update code many times, so after zooming it continues to calculate all the old updates, change the data, then throw it away again for several seconds. I believe that respecting the LODStart and LODEnd events I should be able to fix this trivially, however I can’t work out how to find the LOD status in the python side - the only way I can find to get it is to subscribe to the LODStart and LODEnd in the JS side, and send that back through something like a dummy CDS or non-rendered checkbox. Is there any nicer way?
Thanks
Sam

The events_app.py example shows how register for all the available events in both Python and JS, including the LOD events:

Thank you! Sorry for asking such a basic question - for some reason auto-complete in VSCode was showing me on_change, js_on_change and js_on_event, but wasn’t showing that on_event was a function!

Ah, turns out that LODEnd doesn’t fire for my graphs anyway, due to this bug still being open (LODEnd not firing when there are linked x_ranges) Linking the ranges of plots will break the LODEnd event · Issue #7707 · bokeh/bokeh · GitHub

@samr85 Well that issue clearly fell off the radar. I’d suggest pinging it with a link back to this discussion and I will at least look enough to see if it seems like there is any quick/easy fix

Thank you! not 100% sure what you mean, but have put a link here in the issue. I’d also updated it yesterday with my guess at what the issue was, and some possible fixes - I’m happy to do a pull request to fix it myself if you’d let me know if any of my suggestions are acceptable.