summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_streams.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_asyncio/test_streams.py')
-rw-r--r--Lib/test/test_asyncio/test_streams.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py
index 0a9762d..3b115b1 100644
--- a/Lib/test/test_asyncio/test_streams.py
+++ b/Lib/test/test_asyncio/test_streams.py
@@ -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):