Patchwork ***UNCHECKED*** D9270: httpservice: move sys.exit() out of serve_forever()

login
register
mail settings
Submitter phabricator
Date Nov. 4, 2020, 4:47 a.m.
Message ID <differential-rev-PHID-DREV-4wfplo2h5kof3pqyz7xb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47545/
State Superseded
Headers show

Comments

phabricator - Nov. 4, 2020, 4:47 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9270

AFFECTED FILES
  mercurial/commands.py
  mercurial/debugcommands.py
  mercurial/hgweb/__init__.py
  mercurial/wireprotoserver.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -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."""
diff --git a/mercurial/hgweb/__init__.py b/mercurial/hgweb/__init__.py
--- a/mercurial/hgweb/__init__.py
+++ b/mercurial/hgweb/__init__.py
@@ -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):
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -3376,6 +3376,7 @@ 
 
     s = wireprotoserver.sshserver(ui, repo, logfh=logfh)
     s.serve_forever()
+    sys.exit(0)
 
 
 @command(b'debugsetparents', [], _(b'REV1 [REV2]'))
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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)