I am running a Flask webapp running behind uwsgi (2 processes). A part of my code involves pinging a remote resource, seeing if it has been modified (If-Modified-Since
), and updating a local copy of that resource on the webserver if modified.
That update also sends myself an email of the diff. I'm concerned that this takes a long time, causing user requests to time out while sending the email.
Is the Python threading library the right way to tackle this? (spawn a thread and send the email there?) Will this interfere with uwsgi's processes at all?
Thanks for the help!
(on a side note: I am also a bit concerned about the 2 uwsgi processes bumping heads if they both try to update the resource on the local copy... I wonder if the threading module's lock capabilities is the right thing to look at for this problem as well?)
EDIT: To clarify, my primary concern is that the email task is part of the code execution. It takes a long time and runs before the return_template
call, therefore holding up the response to the user. Is the Python threading library the right way to tackle this problem, given the Flask/uwsgi environment?