Extend/Disable Harakiri for StreamingHttpResponse

I have a Django webapp that allows downloading of data exported from the MySQL DB. I am using a StreamingHttpResponse to download the file, but if there is too much to download (>2.5MB) the download ends prematurely without error. In the server.log is HARAKIRI after 300 seconds. All the other solutions in the forum suggest to avoid taking so long (e.g. #2680) but that isn't really an option here. Is there a way to override the harakiri timeout or reset it like a watchdog?


the 5min limit is a hard limit for files served from your webapp. Here's a couple thoughts:

  1. try serving it as a static file? that might be able to get around this, but you won't be able to control who has access to it
  2. do you know if it's taking a long time to generate the 2.5mb file before returning it to the client, or if the actual file transfer is taking a long time? (i would have expected a 2.5mb file to take < 1 min?) if so, you could try to pre-generate the file?
  3. is your file transfer gzipped etc?
  4. you could try hosting it on s3 and generating per use urls for people accessing it if security is a concern

Hi Conrad,

Thanks for your suggestions. You're right, 2.5MB shouldn't take that long to download, so it is probably slow to generate it. The download is streaming (StreamingHttpResponse) so some of the content gets downloaded, rather than a timeout with no data (before when I was using HttpResponse). I'll have a look at how to speed up the DB query that generates the output line-by-line.