Skip to content

Commit f4e0443

Browse files
committed
fixup! Attempt to pick the fastest network interface for workers
1 parent e816063 commit f4e0443

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

src/network_interfaces.jl

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## This is a minimal version of NetworkInterfaceControllers.jl
1+
## This is a minimal version of NetworkInterfaceControllers.jl, licensed under MIT
22

33
# uv_interface_address_t has a few fields, but we don't support accessing all of
44
# them because `name` is the first field and it's a pointer:
@@ -97,29 +97,34 @@ function _get_interfaces(
9797
(:skip, nothing)
9898
end
9999

100-
# Load sysfs info
101-
sysfs_path = "/sys/class/net/$(name)"
102-
type_path = "$(sysfs_path)/type"
103-
speed_path = "$(sysfs_path)/speed"
104100
type = nothing
105-
if isfile(type_path)
106-
try
107-
type_code = parse(Int, read(type_path, String))
108-
if type_code in Int.(instances(ARPHardware))
109-
type = ARPHardware(type_code)
101+
speed = nothing
102+
103+
@static if Sys.isunix()
104+
# Load sysfs info
105+
sysfs_path = "/sys/class/net/$(name)"
106+
type_path = "$(sysfs_path)/type"
107+
speed_path = "$(sysfs_path)/speed"
108+
109+
if isfile(type_path)
110+
try
111+
type_code = parse(Int, read(type_path, String))
112+
if type_code in Int.(instances(ARPHardware))
113+
type = ARPHardware(type_code)
114+
end
115+
catch
116+
# Do nothing on any failure to read or parse the file
110117
end
111-
catch
112-
# Do nothing on any failure to read or parse the file
113118
end
114-
end
115-
speed = nothing
116-
if isfile(speed_path)
117-
try
118-
reported_speed = parse(Float64, read(speed_path, String))
119-
if reported_speed > 0
120-
speed = reported_speed
119+
120+
if isfile(speed_path)
121+
try
122+
reported_speed = parse(Float64, read(speed_path, String))
123+
if reported_speed > 0
124+
speed = reported_speed
125+
end
126+
catch
121127
end
122-
catch
123128
end
124129
end
125130

0 commit comments

Comments
 (0)