fix shutdown if oml never went online

This commit is contained in:
j 2016-02-24 12:48:01 +05:30
parent c8722855e2
commit 130a900bb0

View file

@ -57,7 +57,7 @@ class Downloads(Thread):
def run(self): def run(self):
self.wait(10) self.wait(10)
while not state.shutdown: while not state.shutdown:
self.wait_online() if self.wait_online():
with db.session(): with db.session():
self.download_next() self.download_next()
self.wait(10) self.wait(10)
@ -68,8 +68,9 @@ class Downloads(Thread):
return Thread.join(self) return Thread.join(self)
def wait_online(self): def wait_online(self):
while not state.online: while not state.online and not state.shutdown:
self.wait(5) self.wait(5)
return not state.shutdown
def wait(self, timeout): def wait(self, timeout):
step = min(timeout, 1) step = min(timeout, 1)