Patchwork [7,of,7] commandserver: drop old unixservice implementation

login
register
mail settings
Submitter Yuya Nishihara
Date July 14, 2016, 3:20 p.m.
Message ID <2a692364f43bf27862ab.1468509645@mimosa>
Download mbox | patch
Permalink /patch/15860/
State Accepted
Headers show

Comments

Yuya Nishihara - July 14, 2016, 3:20 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.
Sean Farley - July 14, 2016, 6:50 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@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.

Wow, thanks for doing this! The patches were a little verbose but look
alright to me (I might do a second pass to make sure). I hope Jun is
able to review these as well. Overall, very happy :-)
Jun Wu - July 15, 2016, 3:37 p.m.
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@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
Augie Fackler - July 15, 2016, 5:23 p.m.
On Fri, Jul 15, 2016 at 12:20:45AM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1463892309 -32400
> #      Sun May 22 13:45:09 2016 +0900
> # Node ID 2a692364f43bf27862ab001b905c5c8d61e59e6d
> # Parent  32d05eda38ffd0a224a77914eea9fa14322aac32
> commandserver: drop old unixservice implementation

Queued this, thanks!

>
> 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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