This morning, I found the answer which was pretty straightforward. I simply have to include and dump it. In every callback I can see (and print) the queue except in the while loop, where I can only see the values before entering the loop (so they don’t get updated while in the while loop)
@app.callback(
[Output('test_graph', 'figure'),
Output('testData', 'data')],
Input('graph-update', 'n_intervals'),
State('myData', 'data'),
State('testData', 'data')
)
def tester(n, xxx, test):
q = json.loads(xxx)
test = json.loads(test)
X.append(X[-1] + 1)
Y.append(float(q[-1]))
test.append(10)
data = plotly.graph_objs.Scatter(
x=list(X),
y=list(Y),
name='Scatter',
mode='lines+markers'
)
return {'data': [data], 'layout': go.Layout(xaxis=dict(range=[min(X), max(X)]),
yaxis=dict(range=[float(min(Y)), float(max(Y))]), )}, json.dumps(test, cls=DequeEncoder)
@jinnyzor , is there a way to also see updates within this while loop?
And additionally, a more theoretical question. Using the current class and json.dump we are no longer working with deque’s, right? So won’t memory issues become a problem if the lists become too long? Something that with a deque is easily solved by setting a maxlen.