From 0a83ea394c5799482e8052aefa4c5cec28128b04 Mon Sep 17 00:00:00 2001
From: Leo Gordon <lg4@ebi.ac.uk>
Date: Thu, 6 Dec 2012 11:18:59 +0000
Subject: [PATCH] bugfix:  -job_limit now works correctly also with
 respecializing workers

---
 modules/Bio/EnsEMBL/Hive/Worker.pm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Hive/Worker.pm b/modules/Bio/EnsEMBL/Hive/Worker.pm
index 179e511d1..b7515586d 100644
--- a/modules/Bio/EnsEMBL/Hive/Worker.pm
+++ b/modules/Bio/EnsEMBL/Hive/Worker.pm
@@ -522,11 +522,12 @@ sub run {
                 } else {
                     my $desired_batch_size = $self->analysis->stats->get_or_estimate_batch_size();
                     $desired_batch_size = $self->job_limiter->preliminary_offer( $desired_batch_size );
-                    $self->job_limiter->final_decision( $desired_batch_size );
 
                     my $actual_batch = $job_adaptor->grab_jobs_for_worker( $self, $desired_batch_size );
                     if(scalar(@$actual_batch)) {
-                        $jobs_done_by_batches_loop += $self->run_one_batch( $actual_batch );
+                        my $jobs_done_by_this_batch = $self->run_one_batch( $actual_batch );
+                        $jobs_done_by_batches_loop += $jobs_done_by_this_batch;
+                        $self->job_limiter->final_decision( $jobs_done_by_this_batch );
                     } else {
                         $self->cause_of_death('NO_WORK');
                     }
-- 
GitLab