changeset 45837:b7b8a1538161

httpservice: move sys.exit() out of serve_forever() This is a simple refactoring to show the callers of the method, so it's easier to reason about the impact of removing the `sys.exit()` calls in subsequent patches. Differential Revision: https://phab.mercurial-scm.org/D9270
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 03 Nov 2020 20:18:26 -0800
parents 58e7ee23ddbd
children d6279c43fc60
files mercurial/commands.py mercurial/debugcommands.py mercurial/hgweb/__init__.py mercurial/wireprotoserver.py
diffstat 4 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Jun 22 22:47:43 2020 -0700
+++ b/mercurial/commands.py	Tue Nov 03 20:18:26 2020 -0800
@@ -6348,6 +6348,7 @@
             )
         s = wireprotoserver.sshserver(ui, repo)
         s.serve_forever()
+        sys.exit(0)
 
     service = server.createservice(ui, repo, opts)
     return server.runservice(opts, initfn=service.init, runfn=service.run)
--- a/mercurial/debugcommands.py	Mon Jun 22 22:47:43 2020 -0700
+++ b/mercurial/debugcommands.py	Tue Nov 03 20:18:26 2020 -0800
@@ -3376,6 +3376,7 @@
 
     s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
     s.serve_forever()
+    sys.exit(0)
 
 
 @command(b'debugsetparents', [], _(b'REV1 [REV2]'))
--- a/mercurial/hgweb/__init__.py	Mon Jun 22 22:47:43 2020 -0700
+++ b/mercurial/hgweb/__init__.py	Tue Nov 03 20:18:26 2020 -0800
@@ -9,6 +9,7 @@
 from __future__ import absolute_import
 
 import os
+import sys
 
 from ..i18n import _
 
@@ -111,6 +112,7 @@
 
     def run(self):
         self.httpd.serve_forever()
+        sys.exit(0)
 
 
 def createapp(baseui, repo, webconf):
--- a/mercurial/wireprotoserver.py	Mon Jun 22 22:47:43 2020 -0700
+++ b/mercurial/wireprotoserver.py	Tue Nov 03 20:18:26 2020 -0800
@@ -8,7 +8,6 @@
 
 import contextlib
 import struct
-import sys
 import threading
 
 from .i18n import _
@@ -851,7 +850,6 @@
     def serve_forever(self):
         self.serveuntil(threading.Event())
         self._ui.restorefinout(self._fin, self._fout)
-        sys.exit(0)
 
     def serveuntil(self, ev):
         """Serve until a threading.Event is set."""