fast shutdown if ids are still synced

This commit is contained in:
j 2016-02-24 12:24:36 +05:30
parent dc7ff544a7
commit 87be2e8aca
1 changed files with 7 additions and 5 deletions

View File

@ -316,7 +316,7 @@ def sync_db():
if sort_ids:
t0 = time.time()
commit = False
for i in item.models.Item.query:
for i in item.models.Item.query.options(load_only('id')):
if i.id not in sort_ids:
i.update(commit=False)
if i.info['mediastate'] == 'unavailable' and state.tasks:
@ -324,12 +324,14 @@ def sync_db():
commit = True
#logger.debug('sync:%s', i)
t0 = maybe_commit(t0)
if state.shutdown:
break
if state.shutdown:
break
if commit:
state.db.session.commit()
cleanup_lists()
cleanup_peers()
if not state.shutdown:
cleanup_lists()
if not state.shutdown:
cleanup_peers()
def cleanup_lists():
import item.models