[open-ils-commits] r16955 - trunk/Open-ILS/src/support-scripts (gmc)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jul 16 09:41:55 EDT 2010


Author: gmc
Date: 2010-07-16 09:41:53 -0400 (Fri, 16 Jul 2010)
New Revision: 16955

Modified:
   trunk/Open-ILS/src/support-scripts/marc_export
Log:
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 <gmc at esilibrary.com>


Modified: trunk/Open-ILS/src/support-scripts/marc_export
===================================================================
--- trunk/Open-ILS/src/support-scripts/marc_export	2010-07-16 13:25:06 UTC (rev 16954)
+++ trunk/Open-ILS/src/support-scripts/marc_export	2010-07-16 13:41:53 UTC (rev 16955)
@@ -21,7 +21,7 @@
 
 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 @@
         'format=s'   => \$format,
         'xml-idl=s'  => \$idl,
         'encoding=s' => \$encoding,
+        'timeout=i'  => \$timeout,
 );
 
 if ($help) {
@@ -45,6 +46,9 @@
  --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 @@
     $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 @@
     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 {



More information about the open-ils-commits mailing list