"RuntimeError: _pending_writes should be non-None" exception when refresh chart webpage

Hi there,
I don’t want to use bokeh serve command to run my script as
it hide all my printed msg to the terminal and the chart is not my main
UI. So that I use programatic server (like server.io_loop.start …). My demo for data flow is here:

However
I got “RuntimeError: _pending_writes should be non-None” exception whenever I refreshed the chart web page (or closed and reopened the web page). Is there anything I misused?

I notice that if I paused reatime adding data, I can refresh the page without any exception, but then if I updated data again, the exception occurred. I tried this by modifying the While loop of DataGen.start to below code:

while True:
s = 0 if in_turn else 1
y = y0 if in_turn else y1
self.BroadCast ({s : {‘x’: idx, ‘y’: y}})
print (“New data for stream {s}: {x} - {y}”.format (s = s, x = idx, y = y))

            idx += 1
            y0 += 1 if in_turn else 0
            y1 += 1 if not in_turn else 0
            in_turn = not in_turn

            if idx % 10 == 0:
                ans = input("Paused.")

            sleep (1)

I
opened localhost:8888 (my setting in the script) that showed charts successfully, waited for “Paused.” in terminal, refresh the page, then continue the script, the exception occurred. I guess that was irrelevant
to the data racing between data generator and chart.
Would you please show me my misuse?

Thanks in advance.

  • Hanh Ha