fast shutdown if ids are still synced
This commit is contained in:
parent
dc7ff544a7
commit
87be2e8aca
1 changed files with 7 additions and 5 deletions
|
@ -316,7 +316,7 @@ def sync_db():
|
||||||
if sort_ids:
|
if sort_ids:
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
commit = False
|
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:
|
if i.id not in sort_ids:
|
||||||
i.update(commit=False)
|
i.update(commit=False)
|
||||||
if i.info['mediastate'] == 'unavailable' and state.tasks:
|
if i.info['mediastate'] == 'unavailable' and state.tasks:
|
||||||
|
@ -324,12 +324,14 @@ def sync_db():
|
||||||
commit = True
|
commit = True
|
||||||
#logger.debug('sync:%s', i)
|
#logger.debug('sync:%s', i)
|
||||||
t0 = maybe_commit(t0)
|
t0 = maybe_commit(t0)
|
||||||
if state.shutdown:
|
if state.shutdown:
|
||||||
break
|
break
|
||||||
if commit:
|
if commit:
|
||||||
state.db.session.commit()
|
state.db.session.commit()
|
||||||
cleanup_lists()
|
if not state.shutdown:
|
||||||
cleanup_peers()
|
cleanup_lists()
|
||||||
|
if not state.shutdown:
|
||||||
|
cleanup_peers()
|
||||||
|
|
||||||
def cleanup_lists():
|
def cleanup_lists():
|
||||||
import item.models
|
import item.models
|
||||||
|
|
Loading…
Reference in a new issue