Skip to content

Commit

Permalink
[Core] Psutil process attr num_fds is not available on Windows (#46329)
Browse files Browse the repository at this point in the history
Per psutil doc, num_fds is not available on Windows so we should exclude it when fetching process attrs.

Signed-off-by: Jiajun Yao <[email protected]>
  • Loading branch information
jjyao authored Jun 28, 2024
1 parent 85f9a08 commit 0aaafbd
Showing 1 changed file with 19 additions and 39 deletions.
58 changes: 19 additions & 39 deletions dashboard/modules/reporter/reporter_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def jsonify_asdict(o) -> str:
),
"component_num_fds": Gauge(
"component_num_fds",
"Number of open fds of all components on the node.",
"Number of open fds of all components on the node (Not available on Windows).",
"count",
COMPONENT_METRICS_TAG_KEYS,
),
Expand All @@ -275,6 +275,21 @@ def jsonify_asdict(o) -> str:
),
}

PSUTIL_PROCESS_ATTRS = (
[
"pid",
"create_time",
"cpu_percent",
"cpu_times",
"cmdline",
"memory_info",
"memory_full_info",
]
+ ["num_fds"]
if sys.platform != "win32"
else []
)

MB = 1024 * 1024

# Types
Expand Down Expand Up @@ -626,20 +641,7 @@ def _get_workers(self):
# the process may have terminated due to race condition.
continue

result.append(
w.as_dict(
attrs=[
"pid",
"create_time",
"cpu_percent",
"cpu_times",
"cmdline",
"memory_info",
"memory_full_info",
"num_fds",
]
)
)
result.append(w.as_dict(attrs=PSUTIL_PROCESS_ATTRS))
return result

def _get_raylet_proc(self):
Expand All @@ -665,35 +667,13 @@ def _get_raylet(self):
if raylet_proc is None:
return {}
else:
return raylet_proc.as_dict(
attrs=[
"pid",
"create_time",
"cpu_percent",
"cpu_times",
"cmdline",
"memory_info",
"memory_full_info",
"num_fds",
]
)
return raylet_proc.as_dict(attrs=PSUTIL_PROCESS_ATTRS)

def _get_agent(self):
# Current proc == agent proc
if not self._agent_proc:
self._agent_proc = psutil.Process()
return self._agent_proc.as_dict(
attrs=[
"pid",
"create_time",
"cpu_percent",
"cpu_times",
"cmdline",
"memory_info",
"memory_full_info",
"num_fds",
]
)
return self._agent_proc.as_dict(attrs=PSUTIL_PROCESS_ATTRS)

def _get_load_avg(self):
if sys.platform == "win32":
Expand Down

0 comments on commit 0aaafbd

Please sign in to comment.