Skip to content

Commit

Permalink
Suppress Py3k resource warnings for sockets.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed May 10, 2013
1 parent aec0978 commit 4a3ffb9
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/ZEO/tests/forker.py
Expand Up @@ -284,6 +284,7 @@ def get_port2(test):
except socket.error as e:
if e.args[0] != errno.EADDRINUSE:
raise
s.close()
continue

if not (can_connect(port) or can_connect(port+1)):
Expand All @@ -297,12 +298,14 @@ def get_port2(test):
def can_connect(port):
c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
c.connect(('localhost', port))
except socket.error:
return False # Perhaps we should check value of error too.
else:
try:
c.connect(('localhost', port))
except socket.error:
return False # Perhaps we should check value of error too.
else:
return True
finally:
c.close()
return True

def setUp(test):
ZODB.tests.util.setUp(test)
Expand Down

0 comments on commit 4a3ffb9

Please sign in to comment.