Stop realtime run on deleted wf instances

This commit is contained in:
Paul Driver 2010-08-13 13:27:33 -07:00
parent b2924bdb7b
commit 890a94d3d5
2 changed files with 7 additions and 2 deletions

View file

@ -1,4 +1,5 @@
7.9.13
- fixed #11783: Instances deleted during realtime run
7.9.12
- webgui.org homepage gives 404 (#11778)

View file

@ -106,7 +106,10 @@ sub delete {
$self->session->db->write("delete from WorkflowInstanceScratch where instanceId=?",[$self->getId]);
$self->session->db->deleteRow("WorkflowInstance","instanceId",$self->getId);
WebGUI::Workflow::Spectre->new($self->session)->notify("workflow/deleteInstance",$self->getId) unless ($skipNotify);
undef $self;
# We will need to remember that we were deleted if we get realtime-run
# during start().
$self->{deleted} = 1;
}
#-------------------------------------------------------------------
@ -645,7 +648,8 @@ sub start {
my $start = time();
my $status = "complete";
$log->info('Trying to execute workflow instance '.$self->getId.' in realtime.');
while ($status eq "complete" && ($start > time() -10)) { # how much can we run in 10 seconds
# If we got deleted in the middle, we need to stop. This is a hack.
while (!$self->{deleted} && $status eq "complete" && ($start > time() -10)) { # how much can we run in 10 seconds
$status = $self->run;
$log->info('Completed activity for workflow instance '.$self->getId.' in realtime with return status of '.$status.'.');
}