Remembering selected points in streaming Bokeh plot

I asked this on StackOverflow here but think maybe this group will be better able to get me to a solution. Here’s my issue:

I want to be able to make a selection (lasso, box_select) of points in a streaming Bokeh scatterplot that will be remembered when the figure updates (e.g., with new data in the time series).

I think this will require me to be able to access the list of the indices of currently selected points, but I can’t figure out how to. Here’s an example where I try (slightly modified from the example at Note that selected points are deselected when the plot updates to the new streamed (shuffled in this example) data.

import time
from random import shuffle
from bokeh.plotting import figure, output_server, cursession, show
# prepare output to server

p = figure(plot_width=400, plot_height=400,tools="lasso_select,box_select,help")
p.scatter([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], name='ex_line')

# create some simple animation..
# first get our figure example data source
renderer ="ex_line"))
ds = renderer[0].
while True:
    # Update y data of the source object

    #Can I access currently selected points? (NO!)
    print ds.selected['2d']
    print ds.selected['1d']
    print ds.selected['0d']

    # store the updated source on the server


Thanks for any help you can provide!