[PATCH 3 of 4 stateful-chg] commandserver: add a heartbeat method to servicehandler

Jun Wu quark at fb.com
Sat May 6 19:39:16 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1493527390 25200
#      Sat Apr 29 21:43:10 2017 -0700
# Node ID ba6bc72d245d779c8951d50eddca1bea9b1b802a
# Parent  1adb2037f0d1f8dc2b84b3804a763ec4c70c00ac
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r ba6bc72d245d
commandserver: add a heartbeat method to servicehandler

This allows chg to do extra things periodically, like checking if there are
repos needed to be preloaded.

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -417,4 +417,8 @@ class unixservicehandler(object):
         os.unlink(address)
 
+    def heartbeat(self):
+        """Called periodically before fork"""
+        pass
+
     def shouldexit(self):
         """True if server should shut down; checked per pollinterval"""
@@ -486,4 +490,6 @@ class unixforkingservice(object):
                 self._unlinksocket()
                 exiting = True
+            else:
+                h.heartbeat()
             try:
                 ready = select.select([self._sock], [], [], h.pollinterval)[0]


More information about the Mercurial-devel mailing list