What's goin' down in groove-town, Monks?

How do you do something akin to a sig alarm in a multi-threaded perl app?

I have an existing perl app that does something similar to a web crawler. It's multi-threaded and uses LWP::UserAgent to pull web pages. Sometimes the connection times out, and I'd like to make that timeout shorter. The timeout value in LWP::UserAgent doesn't seem to do anything in at least one case. This could be because it's actually chasing redirects or something like that. I personally don't care enough to chase down infinite redirects (or whatever it actually is that's taking so long). If this weren't multi-threaded, I'd do sig alarm. But it is multi-threaded!

And now, even more than the practical answer to my problem, I'd like to know how you do a timeout/sig alarm like behaviour in multi-threaded perl?

Thanks!
--Pileofrogs


In reply to Thread Killlin' by pileofrogs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.