# Using die in perl module

**URL:** <https://www.ruby-forum.com/t/using-die-in-perl-module/161157>\
**Category:** NGINX\
**Created:** [February 23, 2009, 11:45pm UTC](https://www.ruby-forum.com/t/using-die-in-perl-module/161157 "2009-02-23T23:45:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Atif\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a4c791/32.png) [@Atif\_G](https://www.ruby-forum.com/u/Atif_G)\
**Post date:** [February 23, 2009, 11:45pm UTC](https://www.ruby-forum.com/t/using-die-in-perl-module/161157/1 "2009-02-23T23:45:50Z")

</div>

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](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 $@;
