Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

How to run Dash app on Heroku in the background job?

This standard dash app:

import dash_table
import pandas as pd
import dash
import psycopg2

conn = psycopg2.connect(
    host="xxxxx.xxxxx.amazonaws.com",
    port = 5432,
    database="xxxxx",
    user="xxxxx",
    password="xxxxxxxxxxx")

statment= f"""
select a,b,c,d, count(c) as count_c
from public.table
group by 1,2,3,4
order by 5 desc
"""
df= pd.read_sql_query(statment ,con=conn)

app = dash.Dash(__name__)

app.layout = dash_table.DataTable(
    columns=[{"name": i, "id": i} for i in df.columns],
    data=df.to_dict('records')
)

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

The problem is that SQL query running 1-2 minutes when Heroku limited runtime only to 30 seconds, and after this get error ‘timeout expired’

The solution is to run the app in the background job.
By Heroku Help Background Tasks in Python with RQ | Heroku Dev Center not so clear how to combine this with Dash App.

Can anyone help how to integrate this with the Dash App?