multithreadingperlcgiperl5.12

perl cgi threads


I am having bit of a problem with my cgi web application, I use ithreads to do some parallel processing, where all the thread have a common 'goal'. Thus I detach all of them, and once I find my answer, I call exit. However the problem is that the script will actually continue processing even after the user has closed the connection and left, which of course if a problem resourcewise. Is there any way to force exit on the parent process if the user has disconnected?


Solution

  • AFAIK create and destroy threads isn't (at least for now) a good Perl practice because it will constantly increase the memory usage!
    You should think in some other way to get the job done. Usually the solution is create a pool of threads and send arguments with the help of a shared array or Thread::Queue.