From: Mike G. v. a. <we...@ma...> - 2005-06-23 02:35:45
|
Log Message: ----------- The TIMEOUT constant which is now defined in WeBWorK::Cosntants and is (and was) used in WeBWorK::PG::Local gives the time in seconds that is allowed for rendering one PG problem. The old value was 5 minutes which was probably way too long. The default in WeBWorK::Constants has been set to 60 seconds. If no value is set then 10 seconds is used. -- Mike Modified Files: -------------- webwork-modperl/lib/WeBWorK: Constants.pm webwork-modperl/lib/WeBWorK/PG: Local.pm Revision Data ------------- Index: Constants.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/Constants.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -Llib/WeBWorK/Constants.pm -Llib/WeBWorK/Constants.pm -u -r1.26 -r1.27 --- lib/WeBWorK/Constants.pm +++ lib/WeBWorK/Constants.pm @@ -65,6 +65,14 @@ $WeBWorK::ContentGenerator::Hardcopy::PreserveTempFiles = 0; ################################################################################ +# WeBWorK::PG::Local +################################################################################ +# The maximum amount of time (in seconds) to work on a single problem. +# At the end of this time a timeout message is sent to the browser. + +$WeBWorK::PG::Local::TIMEOUT = 60; + +################################################################################ # WeBWorK::PG::ImageGenerator ################################################################################ Index: Local.pm =================================================================== RCS file: /webwork/cvs/system/webwork-modperl/lib/WeBWorK/PG/Local.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -Llib/WeBWorK/PG/Local.pm -Llib/WeBWorK/PG/Local.pm -u -r1.17 -r1.18 --- lib/WeBWorK/PG/Local.pm +++ lib/WeBWorK/PG/Local.pm @@ -37,12 +37,13 @@ use strict; use warnings; +use WeBWorK::Constants; use File::Path qw(rmtree); use WeBWorK::PG::Translator; use WeBWorK::Utils qw(readFile writeTimingLogEntry); # Problem processing will time out after this number of seconds. -use constant TIMEOUT => 5*60; +use constant TIMEOUT => $WeBWorK::PG::Local::TIMEOUT || 10; BEGIN { # This safe compartment is used to read the large macro files such as @@ -54,7 +55,7 @@ sub new { my $invocant = shift; - local $SIG{ALRM} = sub { die "Timeout after processing this problem for ", TIMEOUT, " seconds. Check for infinite loops in problem source.\n" }; + local $SIG{ALRM} = \&alarm_handler; alarm TIMEOUT; my $result = eval { $invocant->new_helper(@_) }; alarm 0; @@ -62,6 +63,12 @@ return $result; } +sub alarm_handler { + my $msg = "Timeout after processing this problem for ". TIMEOUT. " seconds. Check for infinite loops in problem source.\n"; + warn $msg; + die $msg; + +} sub new_helper { my $invocant = shift; my $class = ref($invocant) || $invocant; |