multithreading - Thread inside Application vs. Server process -
i have site takes particularly long process request (and that's not defect). 99% of time it's pretty quick because doesn't processing.
i want show message says "loading" when site takes long process request. site uses mod_wsgi , apache. way see it, respond saying 'loading' before completing processing , 1 of 2 things right before:
-spawn (daemon) thread take care of processing.
-communicate through socket other process , tell take care of processing (most send request http://localhost:8080/do_processing).
what pros , cons of 1 approach vs other?
using separate process better. not have hard @ suggested in answer can use existing system doing such celery (http://celeryproject.org/). relying on in process threads not idea unless going implement internal job queueing system of own prevent blowing out of number of threads. also, in multiprocess server configuration cant guaranteed request comes same process , not easy status of running operation. finally, web server processes killed off , background task killed before finishes. need have mechanism holding state can survive such event if important. far easier use celery.
Comments
Post a Comment