Commit 4a3ffb9e authored by Tres Seaver's avatar Tres Seaver

Suppress Py3k resource warnings for sockets.

parent aec09788
...@@ -284,6 +284,7 @@ def get_port2(test): ...@@ -284,6 +284,7 @@ def get_port2(test):
except socket.error as e: except socket.error as e:
if e.args[0] != errno.EADDRINUSE: if e.args[0] != errno.EADDRINUSE:
raise raise
s.close()
continue continue
if not (can_connect(port) or can_connect(port+1)): if not (can_connect(port) or can_connect(port+1)):
...@@ -297,12 +298,14 @@ def get_port2(test): ...@@ -297,12 +298,14 @@ def get_port2(test):
def can_connect(port): def can_connect(port):
c = socket.socket(socket.AF_INET, socket.SOCK_STREAM) c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try: try:
c.connect(('localhost', port)) try:
except socket.error: c.connect(('localhost', port))
return False # Perhaps we should check value of error too. except socket.error:
else: return False # Perhaps we should check value of error too.
else:
return True
finally:
c.close() c.close()
return True
def setUp(test): def setUp(test):
ZODB.tests.util.setUp(test) ZODB.tests.util.setUp(test)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment