|Syntactic Confectionery Delight|
Monitoring Threads and keeping them alive/reviving themby r1n0 (Beadle)
|on Oct 22, 2009 at 15:49 UTC||Need Help??|
r1n0 has asked for the
wisdom of the Perl Monks concerning the following question:
Hello again monks,
I have been toying with threads lately and wanted to know a good method for monitoring threads. If they die, I want to restart them. I ideally want to figure out why a thread dies.
I have done some research on perlmonks and just haven't found the information I am seeking for this topic.
Basically, the code below (StartJobRequest subroutine) is the thread being launched within my code that dies. I don't have all the code here because there are other threads, but none of them seem to be having a problem. I have all kinds of logging happening in my real code to find any problems, but nothing is being identified. So, I am putting the basic thread routine here and asking for help. I am pretty new to threads, so any pointers would be most appreciated. I think it would be great to start a thread that monitors the other threads, and when one dies, start it back up, and hopefully logging will help me find what the issue is.
UPDATE: Since I have posted this message, I have successfully been able to relaunch a thread after it completes. I don't know if this works the same as a thread that dies. I was able to create a monitoring thread, but I wonder what prevents the monitor thread from dieing. And I have been able to start a thread back up from the main program, but in order to do that, I had to have all threads complete. Is this the way that is suppose to work? I have read the cpan page for threads, and there are good examples there, as before I posted this message, but there are some unclear items (as listed with this message) that just aren't too clear to this thread novice. thanks.
Thank you in advance for your help.