def background_thread(ds, year_ds, month_ds, timeseries_ds):
    """Plot animation, update data if play is True, otherwise stop"""
    try:
        while True:
            for year_index in np.arange(2000, 2015, 1):
                    year_ds.data["text"] = [str(year_index)]
                    for month_index in np.arange(1, 13, 1):
                        if should_play():  
                            month_ds.data["text"] = [months_str[1-month_index]]
                            image = get_slice(t, year_index, month_index)
                            date = datetime.date(year_index, month_index, 1)
                            timeseries_ds.data["x"] = [date]
                            timeseries_ds.data["y"] = [df[df.datetime == date].moving_average]
                            ds.data["image"] = [image]
                            cursession().store_objects(ds, year_ds, month_ds, timeseries_ds)
                            time.sleep(0.5)
                        time.sleep(0.5)
    except:
        logger.exception("An error occurred")
        raise


# spin up a background thread
dataset/ETHPy150Open chdoig/scipy2015-blaze-bokeh/animate_widgets.py/background_thread/swapped operands of `-`