Patchwork [4,of,4,stateful-chg] commandserver: allow service to process handler's heartbeat result

login
register
mail settings
Submitter Jun Wu
Date May 6, 2017, 11:39 p.m.
Message ID <e5de933e2325dcc8bbae.1494113957@x1c>
Download mbox | patch
Permalink /patch/20498/
State Accepted
Headers show

Comments

Jun Wu - May 6, 2017, 11:39 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1493533827 25200
#      Sat Apr 29 23:30:27 2017 -0700
# Node ID e5de933e2325dcc8bbaeab17c91b08c203afbdf8
# Parent  ba6bc72d245d779c8951d50eddca1bea9b1b802a
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r e5de933e2325
commandserver: allow service to process handler's heartbeat result

This will be useful for chg where chg handler could tell service to replace
its socket.
Yuya Nishihara - May 9, 2017, 1:57 p.m.
On Sat, 6 May 2017 16:39:17 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1493533827 25200
> #      Sat Apr 29 23:30:27 2017 -0700
> # Node ID e5de933e2325dcc8bbaeab17c91b08c203afbdf8
> # Parent  ba6bc72d245d779c8951d50eddca1bea9b1b802a
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r e5de933e2325
> commandserver: allow service to process handler's heartbeat result
> 
> This will be useful for chg where chg handler could tell service to replace
> its socket.
> 
> diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
> --- a/mercurial/commandserver.py
> +++ b/mercurial/commandserver.py
> @@ -491,5 +491,5 @@ class unixforkingservice(object):
>                  exiting = True
>              else:
> -                h.heartbeat()
> +                self._handleheartbeat(h.heartbeat())
>              try:
>                  ready = select.select([self._sock], [], [], h.pollinterval)[0]
> @@ -524,4 +524,7 @@ class unixforkingservice(object):
>                          os._exit(255)
>  
> +    def _handleheartbeat(self, value):
> +        pass

Does it mean we can't avoid sub-classing the service class?
Jun Wu - May 9, 2017, 5:37 p.m.
Excerpts from Yuya Nishihara's message of 2017-05-09 22:57:23 +0900:
> Does it mean we can't avoid sub-classing the service class?

If that's a goal, a possible solution is to move "_sock" state from service
to handler.

> Added "import socket" in flight.

Sorry. This was depending on "chgserver: add a simple IPC utility"
implicitly.  I didn't notice that when reorder the patches.
Yuya Nishihara - May 10, 2017, 2:09 p.m.
On Tue, 9 May 2017 10:37:25 -0700, Jun Wu wrote:
> Excerpts from Yuya Nishihara's message of 2017-05-09 22:57:23 +0900:
> > Does it mean we can't avoid sub-classing the service class?
> 
> If that's a goal, a possible solution is to move "_sock" state from service
> to handler.

The goal was to split application logic of chg from the service class
so that it would be reusable in prefork model (if any.) I have no idea
how and for what _handleheartbeat() will be used.

Patch

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -491,5 +491,5 @@  class unixforkingservice(object):
                 exiting = True
             else:
-                h.heartbeat()
+                self._handleheartbeat(h.heartbeat())
             try:
                 ready = select.select([self._sock], [], [], h.pollinterval)[0]
@@ -524,4 +524,7 @@  class unixforkingservice(object):
                         os._exit(255)
 
+    def _handleheartbeat(self, value):
+        pass
+
     def _sigchldhandler(self, signal, frame):
         self._reapworkers(os.WNOHANG)