Skip to content
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
10 changes: 9 additions & 1 deletion src/session_info2/_pu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
def cpu_info() -> str:
"""Get CPU info."""
proc = platform.processor() or None
return f"{cpu_count()} logical CPU cores{f', {proc}' if proc else ''}"
total_cores = cpu_count()
try:
available_cores = os.process_cpu_count()
except AttributeError:
Comment thread
jpintar marked this conversation as resolved.
Outdated
try:
available_cores = len(os.sched_getaffinity(0))
except AttributeError:
Comment thread
jpintar marked this conversation as resolved.
Outdated
available_cores = total_cores
return f"{available_cores}/{total_cores} logical CPU cores{f', {proc}' if proc else ''}"


def gpu_info() -> tuple[str, ...]:
Expand Down
Loading