Skip to content

Commit

Permalink
Make global postinglist migration a frequent cron job with bounded ru…
Browse files Browse the repository at this point in the history
…ntime
  • Loading branch information
BjarniRunar committed Oct 23, 2014
1 parent a3a19b7 commit 16d2491
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 1 addition & 5 deletions mailpile/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,11 +1162,7 @@ def _rescan_mailboxes(self, session, which='mailboxes'):
session.ui.mark('\n')

msg_count -= 1
if msg_count:
if not mailpile.util.QUITTING:
GlobalPostingList.Optimize(session, idx, quick=True)
else:
session.ui.mark(_('Nothing changed'))
session.ui.mark(_('Nothing changed'))
except (KeyboardInterrupt, subprocess.CalledProcessError), e:
return {'aborted': True,
'messages': msg_count,
Expand Down
12 changes: 12 additions & 0 deletions mailpile/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,15 @@ def rescan():
lambda: rsc.run(slowly=True))
config.cron_worker.add_task('rescan', rescan_interval, rescan)

from mailpile.postinglist import GlobalPostingList
def optimizer():
config.scan_worker.add_unique_task(
config.background, 'gpl_optimize',
lambda: GlobalPostingList.Optimize(config.background,
config.index,
ratio=0.25, runtime=15))
config.cron_worker.add_task('gpl_optimize', 29, optimizer)

# Schedule plugin jobs
from mailpile.plugins import PluginManager

Expand Down Expand Up @@ -1926,6 +1935,9 @@ def stop_workers(config):
config.save_worker = config.dumb_worker
if config.sys.debug:
print 'Waiting for %s' % save_worker

from mailpile.postinglist import PLC_CACHE_FlushAndClean
PLC_CACHE_FlushAndClean(config.background, keep=0)
save_worker.quit(join=True)

if config.sys.debug:
Expand Down

0 comments on commit 16d2491

Please sign in to comment.