diff options
Diffstat (limited to 'lorrycontroller/givemejob.py')
-rw-r--r-- | lorrycontroller/givemejob.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lorrycontroller/givemejob.py b/lorrycontroller/givemejob.py index 44bf9f7..755def0 100644 --- a/lorrycontroller/givemejob.py +++ b/lorrycontroller/givemejob.py @@ -33,10 +33,9 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute): def run(self, **kwargs): logging.info('%s %s called', self.http_method, self.path) - readdb = self.open_statedb() - if readdb.get_running_queue() and not self.max_jobs_reached(readdb): - statedb = self.open_statedb() - with statedb: + statedb = self.open_statedb() + with statedb: + if statedb.get_running_queue() and not self.max_jobs_reached(statedb): lorry_infos = statedb.get_all_lorries_info() now = statedb.get_current_time() for lorry_info in lorry_infos: |