title: Calling asynchronous function from dash
body: <p>Once a single <code>function</code> needs to be <code>await</code>ed, it seems like a cascading of <code>functions</code> that need to be <code>await</code>ed, until you reach a point where adding <code>await</code> breaks stuff:</p>
  <p>I have <code>dash</code> code that intermittently gets called:</p>
  <pre><code>def get_data(symbolStr):
      print(&quot;Getting AR for&quot;, symbolStr)
      df = amp.get_data_job(symbolStr) #calls async code and need to be awaited
      return df
  </code></pre>
  <p>...</p>
  <pre><code>html.Div(
          dcc.Interval(id='interval1', interval = 900 * 1000, n_intervals=0),
         
      ),   
  html.Div(
          dash_table.DataTable(
              id='table',
              columns=[{&quot;name&quot;: i, &quot;id&quot;: i} for i in magic_columns],
              editable=True,
              row_deletable=True
          ),
      ) 
  
  @app.callback(
      [dash.dependencies.Output('table', 'data')],
      [dash.dependencies.Input('interval1', 'n_intervals')],
      [dash.dependencies.State('table', 'data')]
      )
  
  def update_interval(n, data):
      allSymbolsDf = pd.DataFrame()
  
      for symbolStr in symbolsStr:
          df = get_data(symbolStr)
          allSymbolsDf = allSymbolsDf.append(df)
          time.sleep(3)
     
      return [allSymbolsDf.to_dict('rows')]
  </code></pre>
  <p>Thing is, <code>get_data</code> is a <code>function</code> that calls <code>asynchronous</code> code</p>
  <pre><code>df = amp.get_data_job(symbolStr)
  </code></pre>
  <p>I can't turn the callback <code>update_interval</code> into an <code>asynchronous</code> <code>function</code> (AFAIK). What is the recommended way out of this. I mean, still keeping <code>dash</code>.</p>