Throttle stream events

I am using streams.Selection1D but am getting too many updates while user is still selecting points (while using lasso tool). I see a throttle on callbacks but am not sure how to pass the throttle or throttle_timeout keywords to the stream Selection1D class . There is Selection1DCallback but not sure how it is related and can be used like Selection1D.

Any suggestions ?

@philippjfr found this PR Configurable throttling schemes on ServerCallback by philippjfr · Pull Request #4372 · holoviz/holoviews · GitHub

Did this ever make it to LinkedStreams ?

1 Like

I am asking myself the same question.

Is there a general way to throttle (bokeh tools based) callbacks globally, like panel supports it?

I think you can check

Thank you for that link @ahuang11.

My actual implementation for that usecase does not pass/use the event argument directly. It is something like this MRVE:

import holoviews as hv
from holoviews.streams import Selection1D
import numpy as np

def some_func(index):
    print(f"Selected indices are {index}")

dmap = hv.DynamicMap(lambda: hv.Points(np.random.rand(10, 2))).opts(tools=["lasso_select"])
selection_stream = Selection1D(source=dmap)


As the example shows, the stream delivers the selected indices continuously as soon as the lasso_select tool catches a Point.
Do I have access to inside some_func so I can process the input only when a lasso selection has finished?

You may have to use js_on_event

May I ask you to provide an example or a pointer to a resource? I haven’t worked with js_on_event yet.

In the link above, I think there’s an example. You can get plot by doing hv.renderer("bokeh").get_plot() I think