0

I'm creating a web API whose job is to open and unpack several files (could be thousands depending on the search term). So far, I've got it working well. Using wget or curl to query the API ends up returning the information I want.

My issue is that large searches will timeout in a browser after a few minutes. In a previous incarnation of this, I was able to send garbage headers to the browser to tell it I was still working, but now we've moved to Flask and I'm unsure as to how I keep the browser from timing out.

I have looked at streaming data from Flask but there is no guarantee that any data will arrive by the time the browser closes.

At the moment, our clients would prefer just keeping the current page open instead of another solution like giving them a link to the location of where the data will be located once complete. That said, if there is no way to keep the current page open, I'd be interested in hearing other options.

Edit: In response to a comment below I thought it would be pertinent to know that this API would be very lightly used. Tying up resources is not a problem.

Bojan
  • 1
  • 2
  • 1
    one issue with keeping the connection open while the service fetches information is that it ties up resources while it's blocking on IO. if you have many of those types of requests concurrently, you're needlessly tying up resources that could be spent answering requests. one other option would be for clients to enter a callback URL for your service to send results to after data has all been fetched. HTH – matias elgart Nov 21 '16 at 21:38
  • @matiaselgart This is a valid issue that I have considered, however I'm lucky that this API is not going to be used very often. Tying up resources in this case is not a grave concern. – Bojan Nov 21 '16 at 21:51
  • This answer may be of some help: http://stackoverflow.com/questions/18127128/time-out-issues-with-chrome-and-flask – user3030010 Nov 21 '16 at 21:53

0 Answers0