Skip to content
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

[Windows 10] "conn.bytes_sent" and "conn.bytes_recv" error #2205

Closed
ysn2382617094wsw opened this issue Feb 19, 2023 · 0 comments
Closed

[Windows 10] "conn.bytes_sent" and "conn.bytes_recv" error #2205

ysn2382617094wsw opened this issue Feb 19, 2023 · 0 comments

Comments

@ysn2382617094wsw
Copy link

OS: { Windows 10 }
Architecture: { 64bit}
Psutil version: { 5.8.0 }
Python version: { python3.9.7}

import psutil

def get_process_connections():
connections = psutil.net_connections(kind="inet")
for conn in connections:
process = psutil.Process(conn.pid)
print(f"{process.name()}|{conn.pid}|{conn.bytes_sent}|{conn.bytes_recv}")

if name == "main":
get_process_connections()

This code was written by chatGPT to display the process names of all processes PID|Total amount of uploaded data|Total amount of downloaded data

But chatGPT mainly encounters this "conn.bytes_sent" and "conn.bytes_recv" will always report errors, how can I rewrite it?

error:
Traceback (most recent call last):
File "C:\Users\Wang\PycharmProjects\pythonProject\main.py", line 10, in
get_process_connections()
File "C:\Users\Wang\PycharmProjects\pythonProject\main.py", line 7, in get_process_connections
print(f"{process.name()}|{conn.pid}|{conn.bytes_sent}|{conn.bytes_recv}")
AttributeError: 'sconn' object has no attribute 'bytes_sent'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants