Notify browser/page after long task has ended
Poll the server to get the latest generated files (or the complete list of generated files) every n seconds, and stop the polling once the list is complete, or once the first ajax query (the one which starts the generation process) has completed.
The thread which generates the file should make the list of generated files available in a shared, thread-safe, data-structure.
I am using a Python WebServer (CherryPy), but I guess the question is more open and is fairly general. At the moment, I have some Ajax call trough JQuery load on a button click, that triggers some computation, ending in files generation.
At the moment, as soon as the processing starts in a background thread, my load returns on the page the links to the future files generated on the server. There are several files to be generated, and the whole process can take minutes. How would one manage to display links to files only when they get available, progressively, file by file ? ... At the moment, the links are dead until there are files behind, and I have no way of telling the user when the links get alive.
UPDATE : Thanks JB Nizet. Now could anyone advise about Python Thread safe data structures writing ? Don't know much about the subject, and don't know where to get started.