asyncio/tests: Fix some ResourceWarnings

This commit is contained in:
Yury Selivanov 2015-12-16 19:51:09 -05:00
parent aa78adc589
commit 5f68ca66bf
2 changed files with 18 additions and 13 deletions

View file

@ -647,12 +647,13 @@ os.close(fd)
def server():
# Runs in a separate thread.
sock = socket.socket()
sock.bind(('localhost', 0))
sock.listen(1)
addr = sock.getsockname()
q.put(addr)
clt, _ = sock.accept()
clt.close()
with sock:
sock.bind(('localhost', 0))
sock.listen(1)
addr = sock.getsockname()
q.put(addr)
clt, _ = sock.accept()
clt.close()
@asyncio.coroutine
def client(host, port):