# Try creating a spinner

**URL:** <https://community.plotly.com/t/try-creating-a-spinner/59368>\
**Category:** Dash Python\
**Created:** [December 18, 2021, 5:25pm UTC](https://community.plotly.com/t/try-creating-a-spinner/59368 "2021-12-18T17:25:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bats](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@Bats](https://community.plotly.com/u/Bats)\
**Post date:** [December 18, 2021, 5:25pm UTC](https://community.plotly.com/t/try-creating-a-spinner/59368/1 "2021-12-18T17:25:39Z")

</div>

Hello,  
I’m trying to build a dash app with machine learning models. To visually show that the model is being trained I just wanted to add a spinner while loading. So I coded the following callbacks. When we click on the Run button, I run loading\_gru which chained update\_graph. However once my model-forecast-gru is updated, the loading\_gru function is not called when I put model-forecast-gru as input. I am still new to dash and I don’t understand why it is not working. If you have an explanation or an alternative, I am interested.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/5/b/5bfb5b0a0dc9e0a27766c7b6f162618b155fa690.png)

Thank you for your attention and the time taken to read this message. Thank you for your attention and the time taken to read this message.

---

<div class="post-metadata">

**Author:** ![jlfsjunior](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jlfsjunior/32/16061_2.png) [@jlfsjunior](https://community.plotly.com/u/jlfsjunior)\
**Post date:** [December 18, 2021, 8:22pm UTC](https://community.plotly.com/t/try-creating-a-spinner/59368/2 "2021-12-18T20:22:03Z")

</div>

Hi,

Welcome to the community!

I believe you should have got a “circular callback” error, at least in debug=True mode… In a nutshell, you have an endless loop between the two callbacks, since the output in one triggers (via the input) the other and vice-versa.

The easiest approach is to use the spinner as a `dcc.Loading` component: just wrap the component with id “model-forecast-gru” (a chart, I guess…) in the `dbc.Spinner`, so it will show the spinner while the chart is updated via the callback that trains the model. Just note that there is a risk of timeout if the training takes longer than 30 seconds…

Some links:

- `dcc.Loading`: [Loading | Dash for Python Documentation | Plotly](https://dash.plotly.com/dash-core-components/loading)
- `dbc.Spinner`: [Spinner - dbc docs](https://dash-bootstrap-components.opensource.faculty.ai/docs/components/spinner/) (especially under “Loading components”).

---

<div class="post-metadata">

**Author:** ![Bats](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@Bats](https://community.plotly.com/u/Bats)\
**Post date:** [December 18, 2021, 8:46pm UTC](https://community.plotly.com/t/try-creating-a-spinner/59368/3 "2021-12-18T20:46:18Z")

</div>

Thank you for this quick response.  
I was not aware of this circular callback problem.  
I just tried dcc.loading and it fits my need perfectly.

Thank you for this help, you have helped me a lot
