From: gmc Date: Fri, 16 Jul 2010 15:53:14 +0000 (+0000) Subject: make --timeout actually work if setting a timeout > 60 seconds X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=eb9742e2f8dada2e24fc4feea0edb49060f34cc6;p=evergreen%2Fbjwebb.git make --timeout actually work if setting a timeout > 60 seconds Also remove ersatz XML declarations so that XML output is well-formed. Signed-off-by: Galen Charlton git-svn-id: svn://svn.open-ils.org/ILS/trunk@16964 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/support-scripts/marc_export b/Open-ILS/src/support-scripts/marc_export index 48a9de27a..3740e7fc3 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,$timeout) = ('/openils/conf/opensrf_core.xml','USMARC','MARC8','','$',0); +my ($config,$format,$encoding,$location,$dollarsign,$idl,$help,$holdings,$timeout) = ('/openils/conf/opensrf_core.xml','USMARC','MARC8','','$',0,undef,undef,0); GetOptions( 'help' => \$help, @@ -135,16 +135,20 @@ my $last_time = time; my %count = (); my $speed = 0; while ( my $i = <> ) { - my $bib; - try { - local $SIG{ALRM} = sub { die "TIMEOUT\n" }; - alarm($timeout); - $bib = $ses->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve', $i, $flesh )->gather(1); - alarm(0); - } otherwise { + my $bib; + + my $r = $ses->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve', $i, $flesh ); + my $s = $r->recv(timeout => $timeout); + if ($r->failed) { + warn "\n!!!!!! Failed trying to read record $i: " . $r->failed->stringify . "\n"; + next; + } + if ($r->timed_out) { warn "\n!!!!!! Timed out trying to read record $i\n"; - }; - alarm(0); + next; + } + $bib = $s->content; + $r->finish; $count{bib}++; next unless $bib; @@ -201,7 +205,9 @@ while ( my $i = <> ) { } if (uc($format) eq 'XML') { - print $r->as_xml_record; + my $xml = $r->as_xml_record; + $xml =~ s/^<\?.+?\?>$//mo; + print $xml; } elsif (uc($format) eq 'UNIMARC') { print $r->as_usmarc; } elsif (uc($format) eq 'USMARC') {