dcc.Interval duplicate runs

It looks like the the interval input is being triggered twice every time.
I would expect it to only run once.
Also why is the first value of n_intervals non-zero?

image

import dash
import dash_core_components as dcc
import dash_html_components as html
import datetime as dt

app = dash.Dash()

app.layout = html.Div([
    dcc.Interval(id='my-interval', interval=5*1000, n_intervals=0),
    html.Div(id='display'),
])


@app.callback(
    output=dash.dependencies.Output('display', 'children'),
    inputs=[dash.dependencies.Input('my-interval', 'n_intervals')])
def display_updae(n):
    print (f'n_intervals: {n} ... {str(dt.datetime.now())}')
    return ""


if __name__ == '__main__':
    app.run_server(debug=True)

hm that’s odd. do you happen to have multiple tabs open?

Yes, that was the problem. I had it open on another tab of a virtual desktop.
Thank you.

1 Like