Trouble with add/remove_periodic_callback()

In a program I am writing, I instantiate a series of randomly timed callbacks with add_periodic_callback(callback, random.random() * 150 ). Then, later, when a button is pushed I want to stop the periodic callbacks. I use something like this:

button_stop.on_click(stop_callbacks)

where the stop_callbacks callback, is just

curdoc().remove_periodic_callback(callback)

Unfortunately, this stop_callbacks callback only seems to work and stop the callbacks 1 every 3-4 times. It’s strange behavior. Can anyone help me out with this problem?

Each callback can be added only once (but if you were adding twice it should be throwing a ValueError I believe). That’s the only guess I have based on what you said… maybe you can make a minimal test case and post the runnable code?

Havoc

···

On Tue, Feb 9, 2016 at 4:15 AM, Ricky Galliani [email protected] wrote:

In a program I am writing, I instantiate a series of randomly timed callbacks with add_periodic_callback(callback, random.random() * 150 ). Then, later, when a button is pushed I want to stop the periodic callbacks. I use something like this:

button_stop.on_click(stop_callbacks)

where the stop_callbacks callback, is just

curdoc().remove_periodic_callback(callback)

Unfortunately, this stop_callbacks callback only seems to work and stop the callbacks 1 every 3-4 times. It’s strange behavior. Can anyone help me out with this problem?

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/84d92e74-8a3d-46f5-99f7-bb687ca4e85f%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Havoc Pennington

Senior Software Architect