Python CGI and Browser timeout

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Apr 26 18:26:34 EDT 2007


En Thu, 26 Apr 2007 18:48:29 -0300, <skulka3 at gmail.com> escribió:

> I am creating a simple cgi script which needs to retrieve and process
> a huge number of records from the database (more than 11,000) and
> write the results to a file on disk  and display some results when
> processing is complete.
>
> However, nothing needs to be displayed while the processing is on. I
> was facing browser timeout issue due to the time it takes to process
> these records.
>
> In order to work around this problem, I started printing empty strings
> (i.e. print "") so that the browser does not timeout.
>
> Is there a better solution to avoid browser timeouts?

You could spawn another process or thread, reporting the progress  
somewhere.
Then redirect to another page showing the progress (and auto-reloading  
itself each few seconds).
When it detects that processing is complete, redirect to another page  
showing the final results.

-- 
Gabriel Genellina



More information about the Python-list mailing list