[PATCH 7 of 7] commandserver: drop old unixservice implementation

Jun Wu quark at fb.com
Fri Jul 15 11:37:20 EDT 2016


Thanks for doing this and arranging patches in a review-friendly way!
Finally we can get rid of threads and patching stdlib -- feeling excited!

I have a few comments on PATCH 3, mainly about moving things around a bit.
Otherwise this series look good to me.

Excerpts from Yuya Nishihara's message of 2016-07-15 00:20:45 +0900:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1463892309 -32400
> #      Sun May 22 13:45:09 2016 +0900
> # Node ID 2a692364f43bf27862ab001b905c5c8d61e59e6d
> # Parent  32d05eda38ffd0a224a77914eea9fa14322aac32
> commandserver: drop old unixservice implementation
> 
> It's been superseded by unixforkingservice.
> 
> diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
> --- a/mercurial/commandserver.py
> +++ b/mercurial/commandserver.py
> @@ -25,8 +25,6 @@ from . import (
>      util,
>  )
>  
> -socketserver = util.socketserver
> -
>  logfile = None
>  
>  def log(*args):
> @@ -423,48 +421,19 @@ class unixservicehandler(object):
>          serves for the current connection"""
>          return server(self.ui, repo, fin, fout)
>  
> -class _requesthandler(socketserver.BaseRequestHandler):
> -    def handle(self):
> -        _serverequest(self.server.ui, self.server.repo, self.request,
> -                      self._createcmdserver)
> -
> -    def _createcmdserver(self, repo, conn, fin, fout):
> -        ui = self.server.ui
> -        return server(ui, repo, fin, fout)
> -
> -class unixservice(object):
> +class unixforkingservice(object):
>      """
>      Listens on unix domain socket and forks server per connection
>      """
> -    def __init__(self, ui, repo, opts):
> +
> +    def __init__(self, ui, repo, opts, handler=None):
>          self.ui = ui
>          self.repo = repo
>          self.address = opts['address']
> -        if not util.safehasattr(socketserver, 'UnixStreamServer'):
> +        if not util.safehasattr(socket, 'AF_UNIX'):
>              raise error.Abort(_('unsupported platform'))
>          if not self.address:
>              raise error.Abort(_('no socket path specified with --address'))
> -
> -    def init(self):
> -        class cls(socketserver.ForkingMixIn, socketserver.UnixStreamServer):
> -            ui = self.ui
> -            repo = self.repo
> -        self.server = cls(self.address, _requesthandler)
> -        self.ui.status(_('listening at %s\n') % self.address)
> -        self.ui.flush()  # avoid buffering of status message
> -
> -    def _cleanup(self):
> -        os.unlink(self.address)
> -
> -    def run(self):
> -        try:
> -            self.server.serve_forever()
> -        finally:
> -            self._cleanup()
> -
> -class unixforkingservice(unixservice):
> -    def __init__(self, ui, repo, opts, handler=None):
> -        super(unixforkingservice, self).__init__(ui, repo, opts)
>          self._servicehandler = handler or unixservicehandler(ui)
>          self._sock = None
>          self._oldsigchldhandler = None


More information about the Mercurial-devel mailing list