-
Notifications
You must be signed in to change notification settings - Fork 290
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
Psutil changes in public_ips()
causes breaking changes
#1039
Comments
Thanks for reporting! I'll see if I can find a quick fix. Can you share the full public ips list for the two (feel free to obfuscate part of the ips, I mainly want to see if the lists are the same and how the order differs)? The ordering hasn't ever technically been meaningful, but it's nice when a guess is useful and consistency is important. |
Unfortunately I only have the full list of public ips for the new behavior (before we filter) but here's the list:
Let me know what else I can provide! |
Ah, sorry. You can still compute them both if you have both netifaces and psutil: import netifaces
import psutil
from jupyter_client import localinterfaces
localinterfaces._load_ips_psutil()
print("psutil ", localinterfaces.PUBLIC_IPS)
localinterfaces._load_ips_netifaces()
print("netifaces", localinterfaces.PUBLIC_IPS)
print("psutil ", list(psutil.net_if_addrs()))
print("netifaces", list(netifaces.interfaces())) which give me:
and if you can identify the interface label for each of the ipv4 addresses, e.g. with:
But |
Got it! I can keep the filtering we have. Manually sorting link locals to last or updating the docs that it should be considered an unordered set sounds like a good solution. Might help some users down the road. Thanks! |
Thinking about it, 169.254 probably should be filtered out of public_ips like 127 is. I can't think of what that change would break, but probably something. |
Makes sense to me (though not sure about the unintended breaking changes that may result). The method name
|
#1040 removes link-local addresses from public_ips entirely. BTW, how were you using this? I've used import socket
import psutil
def ip_for_iface(iface="en0"):
"""Return ipv4 address for the given named network interface"""
# select interface
iface_addrs = psutil.net_if_addrs()[iface]
# filter to ipv4
iface_inet = [addr for addr in iface_addrs if addr.family == socket.AF_INET]
# return first ip
return iface_inet[0].address
print(ip_for_iface("en0")) |
This was a naive implementation in Deploying to prod will include specifying a network interface as you indicated above. Thank you and appreciate the prompt patch. |
Introduced in 5d4888116a69b8f8edb69e51a22b8d4df3a54741 in
jupyter_client/localinterfaces.py
, the changes made topublic_ips()
method breaks existing deployments.Previously, the following yielded the correct public ip address:
Now, it yields the linked local address:
For now, I am manually filtering out IPs that are one of: ipv4 link local ips (unicast), ipv6 ips (unicast), ipv4 multicast ips, or ipv6 multicast ips, but would love to see this get fixed upstream.
The text was updated successfully, but these errors were encountered: