8000 gh-109015: Add test.support.socket_helper.tcp_blackhole() by vstinner · Pull Request #109016 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-109015: Add test.support.socket_helper.tcp_blackhole() #109016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use -n option suggested by Ed
  • Loading branch information
vstinner committed Sep 6, 2023
commit 410b2d3e6a3d1233115890eaecefafb7242a9297
6 changes: 3 additions & 3 deletions Lib/test/support/socket_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def _get_sysctl(name):
except KeyError:
pass

cmd = ['sysctl', name]
# At least Linux and FreeBSD support the "-n" option
cmd = ['sysctl', '-n', name]
proc = subprocess.run(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
Expand All @@ -305,8 +306,7 @@ def _get_sysctl(name):

# Parse 'net.inet.tcp.blackhole: 0\n' to get '0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is leftover

try:
value = output.rstrip().split(':', 1)[-1].strip()
value = int(value)
value = int(output.strip())
except Exception as exc:
support.print_warning(f'Failed to parse {' '.join(cmd)!r} '
f'command output {output!r}: {exc!r}')
Expand Down
0