mirror of
https://github.com/python/cpython.git
synced 2025-09-10 02:36:56 +00:00
Closes #14421: use with statement to properly close socket in bandwidth test.
This commit is contained in:
parent
1641bb7669
commit
c0fdf6cf7a
1 changed files with 57 additions and 57 deletions
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue