[MOBY-guts] biomoby commit
Enrique de Andres Saiz
deandres at dev.open-bio.org
Mon Apr 2 07:43:46 UTC 2007
deandres
Mon Apr 2 03:43:46 EDT 2007
Update of /home/repository/moby/moby-live/Perl/MOBY/Async
In directory dev.open-bio.org:/tmp/cvs-serv4062
Modified Files:
Service.pm
Log Message:
Catched INT andt TERM signals for destroying resource
moby-live/Perl/MOBY/Async Service.pm,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/03/15 09:50:50 1.4
+++ /home/repository/moby/moby-live/Perl/MOBY/Async/Service.pm 2007/04/02 07:43:45 1.5
@@ -151,20 +151,16 @@
sub execute {
my ($self, %args) = @_;
- print "Creating WS-Resource...\n\n" unless ($self->{silent});
-
my $start = time;
my ($EPR, @queryIDs) = $self->submit(%args);
- print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent});
-
my $pollingTime;
my ($i, $j) = (0, 1);
my @status;
while ( $pollingTime = &_getPollingTime($i, $j, $start, @status) ) {
($i, $j) = ($j, $i+$j);
- print "Next polling in $pollingTime seconds...\n\n" unless ($self->{silent});
+ print "(next polling in $pollingTime seconds)\n\n" unless ($self->{silent});
sleep $pollingTime;
@status = $self->poll($EPR, @queryIDs);
@@ -177,13 +173,11 @@
}
}
- print "Retrieving results and destroying WS-Resource...\n\n" unless ($self->{silent});
-
my @responses = $self->result($EPR, @queryIDs);
$self->destroy($EPR);
my $response = &_composeResponse(@responses);
- print "Finished.\n" unless ($self->{silent});
+ print "Finished.\n\n" unless ($self->{silent});
return $response;
}
@@ -191,6 +185,8 @@
sub submit {
my ($self, %args) = @_;
+ print "Creating WS-Resource...\n\n" unless ($self->{silent});
+
# Compose the moby message (part of this block is copied from MOBY::Client::Service)
die "ERROR: expected listref for XMLinputlist" unless ( ref( $args{XMLinputlist} ) eq 'ARRAY' );
my @inputs = @{ $args{XMLinputlist} };
@@ -269,6 +265,19 @@
$EPR->Address($address);
$EPR->ReferenceParameters('<moby:ServiceInvocationId xmlns:moby="'.$WSRF::Constants::MOBY.'">'.$identifier.'</moby:ServiceInvocationId>');
+ print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent});
+
+ $SIG{TERM} = sub {
+ $self->destroy($EPR);
+ print "Finished.\n\n" unless ($self->{silent});
+ exit;
+ };
+ $SIG{INT} = sub {
+ $self->destroy($EPR);
+ print "Finished.\n\n" unless ($self->{silent});
+ exit;
+ };
+
# Return Endpoint Reference and the queryIDs
return ($EPR, @queryIDs);
}
@@ -281,15 +290,13 @@
my $start = time;
my ($EPR, @queryIDs) = $self->enumerated_submit(%args);
- print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent});
-
my $pollingTime;
my ($i, $j) = (0, 1);
my @status;
while ( $pollingTime = &_getPollingTime($i, $j, $start, @status) ) {
($i, $j) = ($j, $i+$j);
- print "Next polling in $pollingTime seconds...\n\n" unless ($self->{silent});
+ print "(next polling in $pollingTime seconds)\n\n" unless ($self->{silent});
sleep $pollingTime;
@status = $self->poll($EPR, @queryIDs);
@@ -302,13 +309,11 @@
}
}
- print "Retrieving results and destroying WS-Resource...\n\n" unless ($self->{silent});
-
my @responses = $self->result($EPR, @queryIDs);
$self->destroy($EPR);
my $response = &_composeResponse(@responses);
- print "Finished.\n" unless ($self->{silent});
+ print "Finished.\n\n" unless ($self->{silent});
return $response;
}
@@ -316,6 +321,8 @@
sub enumerated_submit {
my ($self, %args) = @_;
+ print "Creating WS-Resource...\n\n" unless ($self->{silent});
+
# Compose the moby message (part of this block is copied from MOBY::Client::Service)
die "ERROR: expected Input to be a HASH ref" unless ( ref( $args{Input} ) eq 'HASH' );
my %inputs = %{$args{Input}};
@@ -393,6 +400,19 @@
$EPR->Address($address);
$EPR->ReferenceParameters('<moby:ServiceInvocationId xmlns:moby="'.$WSRF::Constants::MOBY.'">'.$identifier.'</moby:ServiceInvocationId>');
+ print XML::LibXML->new->parse_string($EPR->XML)->getDocumentElement()->toString."\n\n" unless ($self->{silent});
+
+ $SIG{TERM} = sub {
+ $self->destroy($EPR);
+ print "Finished.\n\n" unless ($self->{silent});
+ exit;
+ };
+ $SIG{INT} = sub {
+ $self->destroy($EPR);
+ print "Finished.\n\n" unless ($self->{silent});
+ exit;
+ };
+
# Return Endpoint Reference and the queryIDs
return ($EPR, @queryIDs);
}
@@ -400,6 +420,8 @@
sub poll {
my ($self, $EPR, @queryIDs) = @_;
+ print "Polling...\n\n" unless ($self->{silent});
+
my $searchTerm = "";
foreach my $queryID (@queryIDs) {
$searchTerm .= "<wsrp:ResourceProperty xmlns:wsrp=\"$WSRF::Constants::WSRP\">";
@@ -434,6 +456,8 @@
sub result {
my ($self, $EPR, @queryIDs) = @_;
+ print "Retrieving results...\n\n" unless ($self->{silent});
+
my $searchTerm = "";
foreach my $queryID (@queryIDs) {
$searchTerm .= "<wsrp:ResourceProperty xmlns:wsrp=\"$WSRF::Constants::WSRP\">";
@@ -467,6 +491,8 @@
sub destroy {
my ($self, $EPR) = @_;
+ print "Destroying WS-Resource...\n\n" unless ($self->{silent});
+
my $ans = WSRF::Lite
-> uri($WSRF::Constants::WSRL)
-> on_action( sub {sprintf '%s/%s', @_} )
More information about the MOBY-guts
mailing list