[Updated] D9441: run-tests: use a context manager when looking for available ports

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Sat Nov 28 12:07:05 UTC 2020


Closed by commit rHGe1404a75cddd: run-tests: use a context manager when looking for available ports (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D9441?vs=23761&id=23777

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D9441/new/

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -255,9 +255,8 @@
     else:
         family = socket.AF_INET
     try:
-        s = socket.socket(family, socket.SOCK_STREAM)
-        s.bind(('localhost', port))
-        s.close()
+        with socket.socket(family, socket.SOCK_STREAM) as s:
+            s.bind(('localhost', port))
         return True
     except socket.error as exc:
         if exc.errno not in (



To: mharbison72, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20201128/3fa4f022/attachment-0002.html>


More information about the Mercurial-patches mailing list