I have a python script that performs a 10 minute process, save a report to the filesystem, prints info about the outcome (stats, errors, etc.) and then closes. Currently, I run this every time a user needs a report, but the customer base is growing like crazy and I can't keep up with things.
I am planning on creating a web app so that a user can login and supply parameters to the script and launch it with a click of a button. The user would then be provided with a link to see the results of the report. The result needs to be viewable and [upon success] needs to be downloadable by the user.
The script also outputs info about its run, such as errors, exceptions, number of files downloaded, how long it took, etc. I want to be able to return this info to the user, but I also don't want this to be dependent on the session (so I want a user to be able to log in, launch the job, log out, switch computers, log back in, and see everything as if they have been logged on the entire time)
I haven't started the web app portion yet because I am simply scoping out the work, so I don't have any code to post, but so far here are my thoughts:
1) Web API call is made by the app to create a "Job" in a database table 2) A python script (which is running 24/7 checking for new Jobs) sees the new job and starts the process of completing the job (the "Job" is what my current script does) 3) The job completes/fails/stops, updating the Job information in the database, and quits 4) The user is able to see their job info (status of "pending", "started", "completed", "failed", etc. via the web app and see the job's meta data, including the report's download link.
Is there a better or more typical way to do this other than a Python script that runs 24/7 waiting for "Jobs" to be created?
As an extra gotcha, the script also currently outputs status/debug info as it is running. Is there any good way for the user to see that in real time?
Thanks a lot! J
Aucun commentaire:
Enregistrer un commentaire