From 6ff7923d36723a3669af5df93e36bb020f7133f5 Mon Sep 17 00:00:00 2001 From: gmc Date: Fri, 16 Jul 2010 13:41:53 +0000 Subject: [PATCH] add --timeout switch to marc_export Provides way to export bibs with holdings that have a large number of copies attached. Default timeout remains 1 second when exporting bibs; increased to 300 seconds when exporting holdings based on empirical tests on a big database. Signed-off-by: Galen Charlton git-svn-id: svn://svn.open-ils.org/ILS/trunk@16955 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/support-scripts/marc_export | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/support-scripts/marc_export b/Open-ILS/src/support-scripts/marc_export index 101f95b20b..48a9de27a5 100755 --- a/Open-ILS/src/support-scripts/marc_export +++ b/Open-ILS/src/support-scripts/marc_export @@ -21,7 +21,7 @@ use Getopt::Long; my @formats = qw/USMARC UNIMARC XML BRE/; -my ($config,$format,$encoding,$location,$dollarsign,$idl,$help,$holdings) = ('/openils/conf/opensrf_core.xml','USMARC','MARC8','','$'); +my ($config,$format,$encoding,$location,$dollarsign,$idl,$help,$holdings,$timeout) = ('/openils/conf/opensrf_core.xml','USMARC','MARC8','','$',0); GetOptions( 'help' => \$help, @@ -32,6 +32,7 @@ GetOptions( 'format=s' => \$format, 'xml-idl=s' => \$idl, 'encoding=s' => \$encoding, + 'timeout=i' => \$timeout, ); if ($help) { @@ -45,6 +46,9 @@ Usage: $0 [options] --xml-idl or -x Location of the IDL XML --location or -l MARC Location Code for holdings from http://www.loc.gov/marc/organizations/orgshome.html + --timeout Timeout for exporting a single record; increase if you + are using --holdings and are exporting bibs that + have a lot of items attached to them. Example: @@ -71,6 +75,13 @@ if ($format ne 'XML') { $type->require; } +if ($timeout <= 0) { + # set default timeout and/or correct silly user who + # supplied a negative timeout; default timeout of + # 300 seconds if exporting items determined empirically. + $timeout = $holdings ? 300 : 1; +} + OpenSRF::System->bootstrap_client( config_file => $config ); if (!$idl) { @@ -127,7 +138,7 @@ while ( my $i = <> ) { my $bib; try { local $SIG{ALRM} = sub { die "TIMEOUT\n" }; - alarm(1); + alarm($timeout); $bib = $ses->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve', $i, $flesh )->gather(1); alarm(0); } otherwise { -- 2.11.0