[bokeh] Removing a callback twice (or after it's already been run)

This is a current known issue:
  
  https://github.com/bokeh/bokeh/issues/7219

It's possible the simple locking described there by p-himik would offer some help, if anyone wants to make a stab at a small PR, it would be appreciated.

Thanks,

Bryan

···

On Mar 12, 2018, at 08:42, [email protected] wrote:

You may reproduce the issue using this snippet:

from functools import partial
from random import random
from bokeh.plotting import figure, curdoc
from bokeh.plotting import ColumnDataSource
import threading
from bokeh.embed import server_session
import time

doc = curdoc()
source = ColumnDataSource(dict(x=[1, 2], y=[1, 2]))
figure = figure()
figure.circle(x="x", y="y", source=source)

layout = figure
doc.add_root(figure)
server_session(layout, doc.session_context.id)

for i in range(10):
    def producer():
        while True:
            time.sleep(random() * 0.3)

            def stream():
                stream_data = dict(x=[random() * 5], y=[random() * 5])
                #print("producer %s, stream=%s" % (threading.current_thread().getName(), stream_data))
                source.stream(stream_data)
            doc.add_next_tick_callback(partial(stream))

    threading.Thread(target=producer).start()

On Saturday, March 10, 2018 at 5:21:19 AM UTC+1, rkop538 wrote:
- I have several threads listening for updates/changes
- When there is an update, the listening thread calls add_next_tick_callback with partial(function_that_streams_the_change, change_value)

Eventually I get an error: "ValueError: Removing a callback twice (or after it's already been run)"

Is there a way to avoid this? I read there is an issue when you send the same function/callback to add_next_tick_callback.

Thanks

--
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/162daf68-258e-4f1b-863a-bea7d0555b4d%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.