Forum: NGINX Using die in perl module

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Atif G. (Guest)
on 2009-02-24 00:45
(Received via mailing list)
Hi all,

I would like to know the consequence in using alarm  and die in a
perl-handler.
For example consider this
http://wiki.codemongers.com/NginxEmbeddedPerlImageResize

The blocking code is the following

 $image= new Image::Magick;
    $image->Read($real_file_path);
    $image->Scale($dimensions);
    $image->Write($dest_file);


Sometimes this code can hold all resources and normal requests cannot be
served.

So if I follow the example from mod_perl and die in 2 seconds, what will
be
the consequence to the current requests?

my $timeout = 2; # seconds
eval {
  local $SIG{ALRM} =
      sub { die "Sorry, timed out. Please try again\n" };
  alarm $timeout;
  # the operation listed above
  alarm 0;
};


die $@ if $@;
This topic is locked and can not be replied to.