Closes #14421: use with statement to properly close socket in bandwidth test.

This commit is contained in:
Georg Brandl 2012-03-27 07:43:53 +02:00
parent 1641bb7669
commit c0fdf6cf7a
1 changed files with 57 additions and 57 deletions

View File

@ -435,7 +435,7 @@ def run_bandwidth_client(**kwargs):
def run_bandwidth_test(func, args, nthreads):
# Create a listening socket to receive the packets. We use UDP which should
# be painlessly cross-platform.
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
sock.bind(("127.0.0.1", 0))
addr = sock.getsockname()