[Gllug] Re: Timeouts in perl

Richard Jones rich at annexia.org
Mon Nov 6 13:50:17 UTC 2006


On Mon, Nov 06, 2006 at 01:08:23PM +0000, - Tethys wrote:
> Hmmm. No one actually answered this, but I have made some progress. My
> code works perfectly, except for when the long operation is a
> WWW::Mechanize request. Thanks to Robert McKay who first spotted that.
> It doesn't matter whether I use my own timeout routine or Time::Out as
> suggested by a couple of people. So, what is WWW::Mechanize doing to
> screw up my exception handling, and what can I do to get around it?

I suspect that it's blocking alarm signals.  I did a quick grep
through WWW::Mechanize -> LWP -> LWP::Protocol::http -> Net::HTTP and
could see a place where it actual did interfere with the current
signal handlers, but it should be easy enough for you to check this by
running your program under strace and seeing whether signals are
blocked.

That may not help you very much ...  Signals in Perl are weird.  Until
5.7.2 they didn't even work reliably: a signal handler could fire off
at any time and if it did any sort of malloc, then it could corrupt
the heap.  When I was working on Net::FTPServer we first found this
bug [AFAICT no one else had ever spotted it before :-(] and my
coauthor Rob Brown heroically worked out a minimal bit of Perl that
you could write in a signal handler which didn't trigger a memory
allocation.  In Perl 5.7.2 they fixed that by blocking signals
whenever Perl code is running, but between Perl statements (roughly
speaking at every semicolon) checking if any signals have arrived.
Needless to say this is pretty inefficient.

Rich.

-- 
Richard Jones, CTO Merjis Ltd.
Merjis - web marketing and technology - http://merjis.com
Internet Marketing and AdWords courses - http://merjis.com/courses - NEW!
Merjis blog - http://blog.merjis.com - NEW!
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list