CSV export in Stream (from Django admin on Heroku)
I found the solution to the problem. It's not a Heroku timeout because otherwise there would be a H12 timeout in the Heroku log (thanks to Caio of Heroku to point that out).
The problem was the default timeout of Gunicorn wich is 30 seconds. After adding --timeout 600 to the Procfile (at the line of Gunicorn) the problem was gone.
The Procfile now looks like this:
web: gunicorn myapp.wsgi -b 0.0.0.0:$PORT --timeout 600celeryd: python manage.py celeryd -E -B --loglevel=INFO
That's rather not the problem of your script, but the problem of 30 seconds web request default Heroku timeout. You could read this:https://devcenter.heroku.com/articles/request-timeoutand according to this doc - move your CSV export to background process.