##// END OF EJS Templates
run-tests: use a context manager when looking for available ports...
Matt Harbison -
r46569:064449f9 default
parent child Browse files
Show More
@@ -47,6 +47,7 b' from __future__ import absolute_import, '
47
47
48 import argparse
48 import argparse
49 import collections
49 import collections
50 import contextlib
50 import difflib
51 import difflib
51 import distutils.version as version
52 import distutils.version as version
52 import errno
53 import errno
@@ -255,9 +256,8 b' def checkportisavailable(port):'
255 else:
256 else:
256 family = socket.AF_INET
257 family = socket.AF_INET
257 try:
258 try:
258 s = socket.socket(family, socket.SOCK_STREAM)
259 with contextlib.closing(socket.socket(family, socket.SOCK_STREAM)) as s:
259 s.bind(('localhost', port))
260 s.bind(('localhost', port))
260 s.close()
261 return True
261 return True
262 except socket.error as exc:
262 except socket.error as exc:
263 if exc.errno not in (
263 if exc.errno not in (
General Comments 0
You need to be logged in to leave comments. Login now