From 130a900bb0ab326d9db8537f7f0197fb3043bf9c Mon Sep 17 00:00:00 2001 From: j Date: Wed, 24 Feb 2016 12:48:01 +0530 Subject: [PATCH] fix shutdown if oml never went online --- oml/downloads.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/oml/downloads.py b/oml/downloads.py index 9c75473..388cdbd 100644 --- a/oml/downloads.py +++ b/oml/downloads.py @@ -57,10 +57,10 @@ class Downloads(Thread): def run(self): self.wait(10) while not state.shutdown: - self.wait_online() - with db.session(): - self.download_next() - self.wait(10) + if self.wait_online(): + with db.session(): + self.download_next() + self.wait(10) def join(self): self.transfers.commit() @@ -68,8 +68,9 @@ class Downloads(Thread): return Thread.join(self) def wait_online(self): - while not state.online: + while not state.online and not state.shutdown: self.wait(5) + return not state.shutdown def wait(self, timeout): step = min(timeout, 1)