[open-ils-commits] r11624 - branches/rel_1_2_4/Open-ILS/src/perlmods/OpenILS/Utils

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Dec 18 17:46:43 EST 2008


Author: erickson
Date: 2008-12-18 17:46:38 -0500 (Thu, 18 Dec 2008)
New Revision: 11624

Modified:
   branches/rel_1_2_4/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm
Log:
backporting request timeout support

Modified: branches/rel_1_2_4/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm
===================================================================
--- branches/rel_1_2_4/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm	2008-12-18 22:46:24 UTC (rev 11623)
+++ branches/rel_1_2_4/Open-ILS/src/perlmods/OpenILS/Utils/CStoreEditor.pm	2008-12-18 22:46:38 UTC (rev 11624)
@@ -145,6 +145,12 @@
 	return $self->{authtoken};
 }
 
+sub timeout {
+    my($self, $to) = @_;
+    $self->{timeout} = $to if defined $to;
+    return defined($self->{timeout}) ? $self->{timeout} : 60;
+}
+
 # -----------------------------------------------------------------------------
 # fetches the session, creating if necessary.  If 'xact' is true on this
 # object, a db session is created
@@ -258,7 +264,7 @@
 sub request {
 	my( $self, $method, @params ) = @_;
 
-	my $val;
+    my $val;
 	my $err;
 	my $argstr = __arg_to_string( (scalar(@params)) == 1 ? $params[0] : \@params);
 
@@ -270,22 +276,25 @@
 		#throw OpenSRF::EX::ERROR ("CStoreEditor lost it's connection - transaction cannot continue");
 	}
 
+
 	try {
 
-      my $req = $self->session->request($method, @params);
+        my $req = $self->session->request($method, @params);
 
-      if( $self->substream ) {
-         $self->log(D,"running in substream mode");
-         $val = [];
-         while( my $resp = $req->recv ) {
-            push(@$val, $resp->content) if $resp->content;
-         }
-      } else {
-         $val = $req->gather(1);
-      }
+        if($self->substream) {
+            $self->log(D,"running in substream mode");
+            $val = [];
+            while( my $resp = $req->recv(timeout => $self->timeout) ) {
+                push(@$val, $resp->content) if $resp->content;
+            }
 
-		#$val = $self->session->request($method, @params)->gather(1);
+        } else {
+            my $resp = $req->recv(timeout => $self->timeout);
+            $val = $resp->content;
+        }
 
+        $req->finish;
+
 	} catch Error with {
 		$err = shift;
 		$self->log(E, "request error $method : $argstr : $err");
@@ -494,6 +503,7 @@
 	$method =~ s/search/id_list/o if $options->{idlist};
 
     $method =~ s/\.atomic$//o if $self->substream($$options{substream} || 0);
+    $self->timeout($$options{timeout});
 
 	# remove any stale events
 	$self->clear_event;



More information about the open-ils-commits mailing list