[PATCH 4 of 4 V2] chgserver: start background preloading thread
Yuya Nishihara
yuya at tcha.org
Mon Feb 27 11:08:53 EST 2017
On Wed, 22 Feb 2017 18:16:11 -0800, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1487814470 28800
> # Wed Feb 22 17:47:50 2017 -0800
> # Node ID 5c44925eab9a424369967e852b05f42443eac3a6
> # Parent 28571825744fb4f4b424385f55afa9484532ef43
> # Available At https://bitbucket.org/quark-zju/hg-draft
> # hg pull https://bitbucket.org/quark-zju/hg-draft -r 5c44925eab9a
> chgserver: start background preloading thread
>
> A new boolean option chgserver.stateful is added. If set to True, chg master
> will start the background repo preloading thread and becomes stateful.
>
> diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
> --- a/mercurial/chgserver.py
> +++ b/mercurial/chgserver.py
> @@ -37,4 +37,7 @@ Config
> # whether to skip config or env change checks
> skiphash = False
> +
> + # whether to be stateful, and preload repo state in background
> + stateful = False
> """
Let's keep it undocumented for now.
> @@ -582,4 +585,26 @@ class chgunixservicehandler(object):
> self._hashstate, self._baseaddress)
>
> +class chgunixforkingservice(commandserver.unixforkingservice):
> + """like unixforkingservice with an optional chgcache.preloader"""
> +
> + def __init__(self, ui, repo, opts, handler=None):
> + super(chgunixforkingservice, self).__init__(ui, repo, opts, handler)
> + if self.ui.configbool('chgserver', 'stateful'):
> + self._preloader = chgcache.preloader()
> + else:
> + self._preloader = None
> +
> + def init(self):
> + super(chgunixforkingservice, self).init()
> + if self._preloader is not None:
> + self.ui.debug('starting background preloader\n')
> + self._preloader.start()
> +
> + def _cleanup(self):
> + super(chgunixforkingservice, self)._cleanup()
> + if self._preloader is not None:
> + self.ui.debug('stopping background preloader\n')
> + self._preloader.stop()
Can you add a couple of hooks to chgunixservicehandler to isolate chg stuff
from the service class?
More information about the Mercurial-devel
mailing list