Full Code of giampaolo/psutil for AI

master deb0df5b6c6e cached
238 files
2.1 MB
548.6k tokens
2269 symbols
1 requests
Download .txt
Showing preview only (2,190K chars total). Download the full file or copy to clipboard to get everything.
Repository: giampaolo/psutil
Branch: master
Commit: deb0df5b6c6e
Files: 238
Total size: 2.1 MB

Directory structure:
gitextract_40bz1e68/

├── .clang-format
├── .dprint.jsonc
├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug.md
│   │   ├── config.yml
│   │   └── enhancement.md
│   ├── PULL_REQUEST_TEMPLATE.md
│   ├── no-response.yml
│   ├── placeholder
│   └── workflows/
│       ├── bsd.yml
│       ├── build.yml
│       ├── changelog_bot.py
│       ├── changelog_bot.yml
│       ├── issues.py
│       ├── issues.yml
│       └── sunos.yml
├── .gitignore
├── CONTRIBUTING.md
├── HISTORY.rst
├── INSTALL.rst
├── LICENSE
├── MANIFEST.in
├── Makefile
├── README.rst
├── SECURITY.md
├── _bootstrap.py
├── docs/
│   ├── .readthedocs.yaml
│   ├── DEVNOTES
│   ├── Makefile
│   ├── README
│   ├── _ext/
│   │   ├── add_home_link.py
│   │   ├── availability.py
│   │   ├── changelog_anchors.py
│   │   └── check_python_syntax.py
│   ├── _links.rst
│   ├── _static/
│   │   ├── copybutton.js
│   │   ├── css/
│   │   │   └── custom.css
│   │   └── sidebar.js
│   ├── _templates/
│   │   └── layout.html
│   ├── adoption.rst
│   ├── alternatives.rst
│   ├── api.rst
│   ├── changelog.rst
│   ├── conf.py
│   ├── credits.rst
│   ├── devguide.rst
│   ├── faq.rst
│   ├── glossary.rst
│   ├── index.rst
│   ├── install.rst
│   ├── migration.rst
│   ├── platform.rst
│   ├── recipes.rst
│   ├── requirements.txt
│   ├── shell_equivalents.rst
│   └── timeline.rst
├── psutil/
│   ├── __init__.py
│   ├── _common.py
│   ├── _enums.py
│   ├── _ntuples.py
│   ├── _psaix.py
│   ├── _psbsd.py
│   ├── _pslinux.py
│   ├── _psosx.py
│   ├── _psposix.py
│   ├── _pssunos.py
│   ├── _psutil_aix.c
│   ├── _psutil_bsd.c
│   ├── _psutil_linux.c
│   ├── _psutil_osx.c
│   ├── _psutil_sunos.c
│   ├── _psutil_windows.c
│   ├── _pswindows.py
│   └── arch/
│       ├── aix/
│       │   ├── common.c
│       │   ├── common.h
│       │   ├── ifaddrs.c
│       │   ├── ifaddrs.h
│       │   ├── net_connections.c
│       │   ├── net_connections.h
│       │   └── net_kernel_structs.h
│       ├── all/
│       │   ├── errors.c
│       │   ├── init.c
│       │   ├── init.h
│       │   ├── pids.c
│       │   ├── str.c
│       │   └── utils.c
│       ├── bsd/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── heap.c
│       │   ├── init.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── net.c
│       │   ├── proc.c
│       │   ├── proc_utils.c
│       │   └── sys.c
│       ├── freebsd/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   ├── proc_socks.c
│       │   ├── sensors.c
│       │   └── sys_socks.c
│       ├── linux/
│       │   ├── disk.c
│       │   ├── heap.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── net.c
│       │   └── proc.c
│       ├── netbsd/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   └── socks.c
│       ├── openbsd/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   ├── socks.c
│       │   └── users.c
│       ├── osx/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── heap.c
│       │   ├── init.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── net.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   ├── proc_utils.c
│       │   ├── sensors.c
│       │   └── sys.c
│       ├── posix/
│       │   ├── init.c
│       │   ├── init.h
│       │   ├── net.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   ├── sysctl.c
│       │   └── users.c
│       ├── sunos/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── environ.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── net.c
│       │   ├── proc.c
│       │   └── sys.c
│       └── windows/
│           ├── cpu.c
│           ├── disk.c
│           ├── heap.c
│           ├── init.c
│           ├── init.h
│           ├── mem.c
│           ├── net.c
│           ├── ntextapi.h
│           ├── pids.c
│           ├── proc.c
│           ├── proc_handles.c
│           ├── proc_info.c
│           ├── proc_utils.c
│           ├── security.c
│           ├── sensors.c
│           ├── services.c
│           ├── socks.c
│           ├── sys.c
│           └── wmi.c
├── pyproject.toml
├── scripts/
│   ├── battery.py
│   ├── cpu_distribution.py
│   ├── disk_usage.py
│   ├── fans.py
│   ├── free.py
│   ├── ifconfig.py
│   ├── internal/
│   │   ├── README
│   │   ├── bench_oneshot.py
│   │   ├── bench_oneshot_2.py
│   │   ├── convert_readme.py
│   │   ├── download_wheels.py
│   │   ├── find_adopters.py
│   │   ├── find_broken_links.py
│   │   ├── generate_manifest.py
│   │   ├── git_pre_commit.py
│   │   ├── install-sysdeps.sh
│   │   ├── install_pip.py
│   │   ├── print_access_denied.py
│   │   ├── print_announce.py
│   │   ├── print_api_speed.py
│   │   ├── print_dist.py
│   │   ├── print_downloads.py
│   │   ├── print_hashes.py
│   │   ├── print_sysinfo.py
│   │   ├── purge_installation.py
│   │   └── rst_check_dead_refs.py
│   ├── iotop.py
│   ├── killall.py
│   ├── meminfo.py
│   ├── netstat.py
│   ├── nettop.py
│   ├── pidof.py
│   ├── pmap.py
│   ├── procinfo.py
│   ├── procsmem.py
│   ├── ps.py
│   ├── pstree.py
│   ├── sensors.py
│   ├── temperatures.py
│   ├── top.py
│   ├── who.py
│   └── winservices.py
├── setup.py
└── tests/
    ├── README.md
    ├── __init__.py
    ├── test_aix.py
    ├── test_bsd.py
    ├── test_connections.py
    ├── test_contracts.py
    ├── test_heap.py
    ├── test_linux.py
    ├── test_memleaks.py
    ├── test_misc.py
    ├── test_osx.py
    ├── test_posix.py
    ├── test_process.py
    ├── test_process_all.py
    ├── test_scripts.py
    ├── test_sudo.py
    ├── test_sunos.py
    ├── test_system.py
    ├── test_testutils.py
    ├── test_type_hints.py
    ├── test_unicode.py
    └── test_windows.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .clang-format
================================================
# Re-adapted from: https://gist.github.com/JPHutchins/6ef33a52cc92fc4a71996b32b11724b4
# clang-format doc: https://clang.llvm.org/docs/ClangFormatStyleOptions.html

BasedOnStyle: Google
AlignAfterOpenBracket: BlockIndent
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
  AfterCaseLabel: false
  AfterClass: false
  AfterControlStatement: MultiLine
  AfterEnum: false
  AfterExternBlock: false
  AfterFunction: false
  AfterNamespace: false
  AfterObjCDeclaration: false
  AfterStruct: false
  AfterUnion: false
  BeforeCatch: false
  BeforeElse: true
  BeforeLambdaBody: false
  BeforeWhile: false
  IndentBraces: false
  SplitEmptyFunction: false
  SplitEmptyNamespace: false
  SplitEmptyRecord: false
BitFieldColonSpacing: After
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakStringLiterals: true
ColumnLimit: 79
DerivePointerAlignment: false
IndentCaseBlocks: true
IndentCaseLabels: true
IndentWidth: 4
MaxEmptyLinesToKeep: 2
PointerAlignment: Right
SortIncludes: false
SpaceBeforeParens: ControlStatementsExceptControlMacros
UseTab: Never

# Force fun return type and fun definition to stay on 2 different lines:
#    static int
#    foo() {
#       printf();
#    }
AlwaysBreakAfterReturnType: TopLevelDefinitions

# Prevents:
#    foo =
#        Bar(...)
PenaltyBreakAssignment: 400
PenaltyBreakBeforeFirstCallParameter: 0

# Handle macros with no `;` at EOL, so that they don't include the next line
# into them.
StatementMacros:
  - Py_BEGIN_ALLOW_THREADS
  - Py_END_ALLOW_THREADS


================================================
FILE: .dprint.jsonc
================================================
{
    "markdown": {
        "lineWidth": 79,
        "textWrap": "always",
    },
    "json": {
        "indentWidth": 4,
        "associations": [
            "**/*.json",
            "**/*.jsonc",
        ],
    },
    "yaml": {
        "associations": [
            "**/*.yml",
            "**/*.yaml",
            "**/.clang-format",
        ],
    },
    "excludes": [
        "**/*-lock.json",
        ".github/ISSUE_TEMPLATE/bug.md",
        ".github/ISSUE_TEMPLATE/enhancement.md",
        ".github/PULL_REQUEST_TEMPLATE.md",
    ],
    "plugins": [
        "https://plugins.dprint.dev/markdown-0.21.1.wasm",
        "https://plugins.dprint.dev/json-0.21.1.wasm",
        "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.6.0.wasm",
    ],
}


================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms

tidelift: "pypi/psutil"
github: giampaolo
patreon: # Replace with a single Patreon username
open_collective: psutil
ko_fi: # Replace with a single Ko-fi username
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A9ZS7PKKRM3S8


================================================
FILE: .github/ISSUE_TEMPLATE/bug.md
================================================
---
name: Bug
about: Report a bug
title: "[OS] title"
labels: 'bug'
---

## Summary

- OS: { type-or-version }
- Architecture: { 64bit, 32bit, ARM, PowerPC, s390 }
- Psutil version: { pip3 show psutil }
- Python version: { python3 -V }
- Type: { core, doc, performance, scripts, tests, wheels, new-api, installation }

## Description

{{{
  A clear explanation of the bug, including traceback message (if any). Please read the contributing guidelines before submit:
  https://github.com/giampaolo/psutil/blob/master/CONTRIBUTING.md
}}}


================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: false
contact_links:
  - name: Ask a question
    url: https://groups.google.com/g/psutil
    about: Use this to ask for support


================================================
FILE: .github/ISSUE_TEMPLATE/enhancement.md
================================================
---
name: Enhancement
about: Propose an enhancement
labels: 'enhancement'
title: "[OS] title"
---

## Summary

- OS: { type-or-version }
- Type: { core, doc, performance, scripts, tests, wheels, new-api }

## Description

{{{
  A clear explanation of your proposal. Please read the contributing guidelines before submit:
  https://github.com/giampaolo/psutil/blob/master/CONTRIBUTING.md
}}}


================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
## Summary

- OS: { type-or-version }
- Bug fix: { yes/no }
- Type: { core, doc, performance, scripts, tests, wheels, new-api }
- Fixes: { comma-separated list of issues fixed by this PR, if any }

## Description

{{{
  A clear explanation of your bugfix or enhancement. Please read the contributing guidelines before submit:
  https://github.com/giampaolo/psutil/blob/master/CONTRIBUTING.md
}}}


================================================
FILE: .github/no-response.yml
================================================
# Configuration for probot-no-response: https://github.com/probot/no-response

# Number of days of inactivity before an issue is closed for lack of response
daysUntilClose: 14
# Label requiring a response
responseRequiredLabel: need-more-info
# Comment to post when closing an Issue for lack of response.
# Set to `false` to disable
closeComment: >
  This issue has been automatically closed because there has been no response for more information from the original author. Please reach out if you have or find the answers requested so that this can be investigated further.


================================================
FILE: .github/placeholder
================================================


================================================
FILE: .github/workflows/bsd.yml
================================================
# Execute tests on *BSD platforms. Does not produce wheels.
# Useful URLs:
# https://github.com/vmactions/freebsd-vm
# https://github.com/vmactions/openbsd-vm
# https://github.com/vmactions/netbsd-vm

on:
  push:
    # only run this job if the following files are modified
    paths: &bsd_paths
      - ".github/workflows/bsd.yml"
      - "psutil/__init__.py"
      - "psutil/_common.py"
      - "psutil/_ntuples.py"
      - "psutil/_psbsd.py"
      - "psutil/_psposix.py"
      - "psutil/_psutil_bsd.c"
      - "psutil/arch/bsd/**"
      - "psutil/arch/freebsd/**"
      - "psutil/arch/netbsd/**"
      - "psutil/arch/openbsd/**"
      - "psutil/arch/posix/**"
      - "setup.py"
      - "tests/**"
  pull_request:
    paths: *bsd_paths
name: bsd
concurrency:
  group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }}
  cancel-in-progress: true
jobs:
  freebsd:
    # if: false
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Run tests
        uses: vmactions/freebsd-vm@v1
        with:
          usesh: true
          run: |
            make ci-test

  openbsd:
    # if: false
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Run tests
        uses: vmactions/openbsd-vm@v1
        with:
          usesh: true
          run: |
            make ci-test

  netbsd:
    # if: false
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Run tests
        uses: vmactions/netbsd-vm@v1
        with:
          usesh: true
          run: |
            make ci-test


================================================
FILE: .github/workflows/build.yml
================================================
# Runs CI tests and generates wheels on the following platforms:
# * Linux
# * macOS
# * Windows
#
# Useful URLs:
# * https://github.com/pypa/cibuildwheel
# * https://github.com/actions/checkout
# * https://github.com/actions/setup-python
# * https://github.com/actions/upload-artifact

on: [push, pull_request]
name: build
concurrency:
  # Cancel build if a new one starts, but don't interrupt all jobs on the first
  # failure.
  group: build-${{ github.ref }}
  cancel-in-progress: true
jobs:

  # Run tests on Linux, macOS, Windows
  tests:
    name: "${{ matrix.os }}, ${{ matrix.arch }}"
    runs-on: ${{ matrix.os }}
    timeout-minutes: 15
    strategy:
      fail-fast: false
      matrix:
        include:
          - { os: ubuntu-latest, arch: x86_64 }
          - { os: ubuntu-24.04-arm, arch: aarch64 }
          - { os: macos-15, arch: x86_64 }
          - { os: macos-15, arch: arm64 }
          - { os: windows-2025, arch: AMD64 }
          - { os: windows-11-arm, arch: ARM64 }
    steps:
      - uses: actions/checkout@v5

      # Install Python 3.8 on macOS ARM64 for universal2 support, else 3.11
      - name: Install Python
        uses: actions/setup-python@v6
        with:
          python-version: ${{ runner.os == 'macOS' && runner.arch == 'ARM64' && '3.8' || '3.11' }}

      - name: Build wheels + run tests
        uses: pypa/cibuildwheel@v3.2.1
        env:
          CIBW_ARCHS: "${{ matrix.arch }}"
          CIBW_ENABLE: "cpython-freethreading ${{ startsWith(github.ref, 'refs/tags/') && '' || 'cpython-prerelease' }}"

      - name: Upload wheels
        uses: actions/upload-artifact@v4
        with:
          name: wheels-${{ matrix.os }}-${{ matrix.arch }}
          path: wheelhouse

  # Run linters and build doc.
  linters-and-doc:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-python@v6
        with:
          python-version: 3.x
      - name: "Run linters"
        run: |
          make ci-lint
      - name: "Build doc"
        run: |
          pip install -r docs/requirements.txt
          cd docs && make html

  # Merge wheels and check sanity of the package distribution.
  merge-and-check-dist:
    needs: [tests]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-python@v6
        with:
          python-version: 3.x
      - uses: actions/upload-artifact/merge@v4
        with:
          name: wheels
          pattern: wheels-*
          separate-directories: false
          delete-merged: true
      - uses: actions/download-artifact@v4
        with:
          name: wheels
          path: wheelhouse
      - run: |
          make ci-check-dist


================================================
FILE: .github/workflows/changelog_bot.py
================================================
# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Activated when commenting "/changelog" on a PR.

This bot will ask Claude to add an entry into docs/changelog.rst based
on the changes introduced in the PR, and also add an entry to
docs/credits.rst.

Requires:

- A subscription to Claude API
- The "ANTHROPIC_API_KEY" environment variable to be set via GitHub
  web interface (Settings -> Secrets & Variables)
"""

import argparse
import datetime
import json
import os
import re
import sys
import urllib.request

import anthropic

# CLI args
PR_NUMBER = None
REPO = None
TOKEN = None

CHANGELOG_FILE = "docs/changelog.rst"
CREDITS_FILE = "docs/credits.rst"
MAX_DIFF_CHARS = 20_000
MAX_TOKENS = 1024

PROMPT = """\
You are helping maintain the official changelog for psutil, a Python
system monitoring library.

Your task is to generate ONE changelog entry describing the user-visible
change introduced by a pull request. Do not generate more than one entry.

PR #{number}: {title}
Author: @{author} (full name: {author_name})

Description:
{body}

Diff:
{diff}

ISSUE NUMBER SELECTION

The changelog should reference the GitHub ISSUE number when one exists,
not the pull request number.

Determine the correct issue number using these rules:

1. If the PR title or description references an issue such as:
   - "Fixes #1234"
   - "Closes #1234"
   - "Refs #1234"
   - "#1234"
   then use that number.

2. If multiple issues are referenced, choose the primary one most
   closely related to the change.

3. If no issue reference exists, fall back to the PR number.

The chosen number will be used in the :gh:`...` role.

STYLE

- Write concise entries (1-2 sentences max).
- Focus on the user-visible behavior change.
- Avoid implementation details unless relevant.
- Prefer imperative verbs: "fix", "add", "improve", "avoid", "detect".
- Do not repeat the PR title verbatim.
- Do not mention "PR" in the text.
- Wrap lines around ~79 characters.

CLASSIFICATION

Classify the change into one of:

Bug fixes
Enhancements

Bug fixes include:
- crashes
- incorrect behavior
- race conditions
- compilation failures
- incorrect return values
- memory leaks
- platform regressions

Enhancements include:
- new features
- performance improvements
- better detection
- improved error handling
- new platform support
- packaging improvements (e.g. wheels)

PLATFORM TAGS

If the change is platform specific, add tags immediately after the issue
reference.

Examples:

:gh:`1234`, [Linux]:
:gh:`1234`, [Windows]:
:gh:`1234`, [macOS], [BSD]:

Only add platform tags if the change clearly affects specific OSes.

RST FORMATTING

Use Sphinx roles for psutil APIs:

Functions:
:func:`function_name`

Methods:
:meth:`Class.method`

Classes:
:class:`ClassName`

Exceptions:
:exc:`ExceptionName`

C functions or identifiers must use double backticks:

``function_name()``

FORMAT

Each entry must follow this structure:

- :gh:`ISSUE_NUMBER`: <description>.

Or with platforms:

- :gh:`ISSUE_NUMBER`, [Linux]: <description>.

DESCRIPTION GUIDELINES

- Describe the user-visible change.
- Mention affected psutil APIs when applicable.
- Avoid mentioning internal helper functions.
- If fixing incorrect behavior, describe the previous issue.
- If fixing a crash or compilation error, state it clearly.

EXAMPLES

- :gh:`2708`, [macOS]: :meth:`Process.cmdline()` and
  :meth:`Process.environ()` may fail with ``OSError: [Errno 0]``.
  They now raise :exc:`AccessDenied` instead.

- :gh:`2674`, [Windows]: :func:`disk_usage()` could truncate values on
  32-bit systems for drives larger than 4GB.

- :gh:`2705`, [Linux]: :meth:`Process.wait()` now uses
  ``pidfd_open()`` + ``poll()`` for waiting, avoiding busy loops
  and improving response times.

CREDITS

psutil maintains a list of contributors in docs/credits.rst under
"Code contributors by year".

Generate a credits entry unless the author is @giampaolo, in which
case set credits_entry to null.

Use the contributor's full name from their GitHub profile ({author_name})
unless it is not set, in which case fall back to their username (@{author}).

The format used in docs/credits.rst is:

* `Name or username`_ - :gh:`ISSUE_NUMBER`

Examples:

* `Sergey Fedorov`_ - :gh:`2701`
* `someuser`_ - :gh:`2710`

Use the same issue number used in the changelog entry.
"""

SUBMIT_TOOL = {
    "name": "submit",
    "description": "Submit the changelog and credits entries.",
    "input_schema": {
        "type": "object",
        "properties": {
            "section": {
                "type": "string",
                "enum": ["Bug fixes", "Enhancements"],
            },
            "changelog_entry": {
                "type": "string",
                "description": "The RST changelog entry.",
            },
            "credits_entry": {
                "type": ["string", "null"],
                "description": (
                    "The RST credits line, or null if author is @giampaolo."
                ),
            },
        },
        "required": ["section", "changelog_entry", "credits_entry"],
    },
}


def gh_request(path, accept="application/vnd.github+json"):
    url = f"https://api.github.com{path}"
    req = urllib.request.Request(
        url,
        headers={
            "Authorization": f"Bearer {TOKEN}",
            "Accept": accept,
            "X-GitHub-Api-Version": "2022-11-28",
        },
    )
    with urllib.request.urlopen(req) as resp:
        return resp.read()


def fetch_pr_metadata():
    pr = json.loads(gh_request(f"/repos/{REPO}/pulls/{PR_NUMBER}"))
    author = pr["user"]["login"]
    # Fetch the user profile to get the full name.
    user = json.loads(gh_request(f"/users/{author}"))
    author_name = user.get("name") or author
    return {
        "number": pr["number"],
        "title": pr["title"],
        "body": pr.get("body") or "",
        "author": author,
        "author_name": author_name,
    }


def fetch_pr_diff():
    return gh_request(
        f"/repos/{REPO}/pulls/{PR_NUMBER}",
        accept="application/vnd.github.v3.diff",
    ).decode("utf-8", errors="replace")


def ask_claude(pr, diff):
    prompt = PROMPT.format(
        number=pr["number"],
        title=pr["title"],
        author=pr["author"],
        author_name=pr["author_name"],
        body=pr["body"],
        diff=diff[:MAX_DIFF_CHARS],
    )
    api_key = os.environ.get("ANTHROPIC_API_KEY", "").strip()
    client = anthropic.Anthropic(api_key=api_key)
    message = client.messages.create(
        model="claude-sonnet-4-6",
        max_tokens=MAX_TOKENS,
        tools=[SUBMIT_TOOL],
        tool_choice={"type": "tool", "name": "submit"},
        messages=[{"role": "user", "content": prompt}],
    )
    tool_use = next(b for b in message.content if b.type == "tool_use")
    return tool_use.input


def insert_changelog_entry(section, entry):
    with open(CHANGELOG_FILE) as f:
        lines = f.readlines()

    version_re = re.compile(r"^(\d+\.\d+\.\d+|X\.X\.X).*$")
    version_idx = next(
        (i for i, ln in enumerate(lines) if version_re.match(ln.rstrip())),
        None,
    )
    if version_idx is None:
        sys.exit(f"Could not find version block in {CHANGELOG_FILE}")
    next_version_idx = next(
        (
            i
            for i in range(version_idx + 1, len(lines))
            if version_re.match(lines[i].rstrip())
        ),
        len(lines),
    )
    block = lines[version_idx:next_version_idx]

    # Skip if this issue is already referenced in the version block
    gh_ref = re.search(r":gh:`\d+`", entry)
    if gh_ref and any(gh_ref.group(0) in ln for ln in block):
        print(
            f"Changelog entry for {gh_ref.group(0)} already exists, skipping"
        )
        return

    header = f"**{section}**"
    header_idx = next(
        (i for i, ln in enumerate(block) if ln.rstrip() == header), None
    )

    def _entry_gh_number(line):
        """Extract the ticket number from a :gh:`N` reference."""
        m = re.search(r":gh:`(\d+)`", line)
        return int(m.group(1)) if m else None

    new_entry_num = _entry_gh_number(entry)

    if header_idx is None:
        insert_at = next(
            (
                i
                for i, ln in enumerate(block)
                if ln.startswith("**") and ln.rstrip() != header
            ),
            len(block),
        )
        new_block = (
            block[:insert_at]
            + [f"{header}\n", "\n", f"{entry}\n", "\n"]
            + block[insert_at:]
        )
    else:
        # Find the end of this section (next ** header or end of block).
        section_end = next(
            (
                i
                for i in range(header_idx + 1, len(block))
                if block[i].startswith("**")
            ),
            len(block),
        )
        # Skip the blank line after the header.
        first_entry = header_idx + 1
        if first_entry < len(block) and not block[first_entry].strip():
            first_entry += 1
        # Find the right position sorted by ticket number.
        insert_at = section_end
        if new_entry_num is not None:
            for i in range(first_entry, section_end):
                num = _entry_gh_number(block[i])
                if num is not None and num > new_entry_num:
                    insert_at = i
                    break
        else:
            insert_at = first_entry
        new_block = block[:insert_at] + [f"{entry}\n"] + block[insert_at:]

    lines[version_idx:next_version_idx] = new_block
    with open(CHANGELOG_FILE, "w") as f:
        f.writelines(lines)


def update_credits(credits_entry, author, author_name):
    """Insert credits entry and link definition into CREDITS_FILE."""
    with open(CREDITS_FILE) as f:
        lines = f.readlines()

    year = str(datetime.date.today().year)
    year_re = re.compile(r"^\d{4}$")

    def sort_key(e):
        m = re.match(r"\*\s+`([^`]+)`_", e.strip())
        return m.group(1).lower() if m else e.strip().lower()

    # Insert year entry
    section_idx = next(
        (
            i
            for i, ln in enumerate(lines)
            if ln.rstrip() == "Code contributors by year"
        ),
        None,
    )
    if section_idx is None:
        sys.exit(
            f"Could not find 'Code contributors by year' in {CREDITS_FILE}"
        )

    year_idx = next(
        (
            i
            for i in range(section_idx, len(lines))
            if lines[i].rstrip() == year
        ),
        None,
    )
    if year_idx is None:
        first_year = next(
            (
                i
                for i in range(section_idx, len(lines))
                if year_re.match(lines[i].rstrip())
            ),
            len(lines),
        )
        lines[first_year:first_year] = [
            f"{year}\n",
            "~" * len(year) + "\n",
            "\n",
            f"{credits_entry}\n",
            "\n",
        ]
    else:
        year_end = next(
            (
                i
                for i in range(year_idx + 2, len(lines))
                if year_re.match(lines[i].rstrip())
            ),
            len(lines),
        )
        new_key = sort_key(credits_entry)
        insert_idx = year_end
        skip = False
        for i in range(year_idx + 2, year_end):
            if lines[i].startswith("* "):
                k = sort_key(lines[i])
                if k == new_key:
                    print(
                        f"Credits entry for {new_key!r} already exists,"
                        " skipping"
                    )
                    skip = True
                    break
                if k > new_key:
                    insert_idx = i
                    break
        if not skip:
            # Don't back up past the blank line after the year
            # underline (year_idx + 2 = "~~~~\n", + 3 = first
            # content line).
            min_idx = year_idx + 3
            while insert_idx > min_idx and not lines[insert_idx - 1].strip():
                insert_idx -= 1
            lines.insert(insert_idx, f"{credits_entry}\n")

    # Insert link definition if missing
    target = f".. _`{author_name}`:"
    if not any(ln.startswith(target) for ln in lines):
        link_section = next(
            (
                i
                for i, ln in enumerate(lines)
                if ln.rstrip() == ".. Code contributors"
            ),
            None,
        )
        if link_section is None:
            sys.exit(
                "Could not find code contributors link section in"
                f" {CREDITS_FILE}"
            )
        definition = f".. _`{author_name}`: https://github.com/{author}\n"
        insert_idx = len(lines)
        for i in range(link_section, len(lines)):
            m = re.match(r"\.\. _`([^`]+)`:", lines[i])
            if m and m.group(1).lower() > author_name.lower():
                insert_idx = i
                break
        lines.insert(insert_idx, definition)

    with open(CREDITS_FILE, "w") as f:
        f.writelines(lines)


def post_comment(body):
    url = f"https://api.github.com/repos/{REPO}/issues/{PR_NUMBER}/comments"
    data = json.dumps({"body": body}).encode()
    req = urllib.request.Request(
        url,
        data=data,
        headers={
            "Authorization": f"Bearer {TOKEN}",
            "Accept": "application/vnd.github+json",
            "Content-Type": "application/json",
            "X-GitHub-Api-Version": "2022-11-28",
        },
    )
    with urllib.request.urlopen(req):
        pass


def parse_cli():
    global PR_NUMBER, REPO, TOKEN
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument("--pr-number", type=int, required=True)
    p.add_argument(
        "--repo", type=str, required=True, help="e.g. giampaolo/psutil"
    )
    p.add_argument("--token", type=str, required=True, help="GitHub token")
    args = p.parse_args()
    PR_NUMBER = args.pr_number
    REPO = args.repo
    TOKEN = args.token


def main():
    parse_cli()
    print(f"Fetching PR #{PR_NUMBER} from {REPO}...")
    pr = fetch_pr_metadata()
    diff = fetch_pr_diff()
    print("Asking Claude for changelog entry...")
    result = ask_claude(pr, diff)
    section = result["section"]
    changelog_entry = result["changelog_entry"]
    credits_entry = result["credits_entry"]
    print(f"Section: {section}")
    print(f"Entry:   {changelog_entry}")
    insert_changelog_entry(section, changelog_entry)
    print(f"Inserted entry into {CHANGELOG_FILE}")
    comment = (
        f"`{CHANGELOG_FILE}` entry added under **{section}**:\n\n"
        f"```rst\n{changelog_entry}\n```"
    )
    if credits_entry:
        print(f"Credits: {credits_entry}")
        update_credits(credits_entry, pr["author"], pr["author_name"])
        print(f"Updated {CREDITS_FILE}")
        comment += (
            f"\n\n`{CREDITS_FILE}` entry added:\n\n"
            f"```rst\n{credits_entry}\n```"
        )
    post_comment(comment)
    print("Posted confirmation comment on PR")


if __name__ == "__main__":
    main()


================================================
FILE: .github/workflows/changelog_bot.yml
================================================
name: changelog-bot

on:
  issue_comment:
    types: [created]

permissions:
  contents: write
  pull-requests: write

jobs:
  changelog:
    if: >
      github.event.comment.body == '/changelog' &&
      github.event.issue.pull_request != null
    runs-on: ubuntu-latest

    steps:
      - name: Check commenter permissions
        id: check-perms
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          PERMISSION=$(gh api \
            repos/${{ github.repository }}/collaborators/${{ github.event.comment.user.login }}/permission \
            --jq '.permission')
          echo "permission=$PERMISSION"
          if [[ "$PERMISSION" != "write" && "$PERMISSION" != "admin" ]]; then
            echo "User ${{ github.event.comment.user.login }} does not have write/admin permission"
            exit 1
          fi

      - name: Get PR info
        id: pr-info
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          PR_NUMBER=${{ github.event.issue.number }}
          PR_JSON=$(gh pr view $PR_NUMBER \
            --repo ${{ github.repository }} \
            --json headRefName,headRepository,headRepositoryOwner)
          HEAD_BRANCH=$(echo "$PR_JSON" | jq -r '.headRefName')
          HEAD_OWNER=$(echo "$PR_JSON" | jq -r '.headRepositoryOwner.login')
          HEAD_REPO=$(echo "$PR_JSON" | jq -r '.headRepository.name')
          echo "branch=$HEAD_BRANCH" >> "$GITHUB_OUTPUT"
          echo "head_repo=$HEAD_OWNER/$HEAD_REPO" >> "$GITHUB_OUTPUT"

      - name: Checkout PR branch
        uses: actions/checkout@v5
        with:
          ref: refs/pull/${{ github.event.issue.number }}/head
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Install dependencies
        run: pip install anthropic

      - name: Run changelog bot
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        run: |
          python .github/workflows/changelog_bot.py \
            --pr-number ${{ github.event.issue.number }} \
            --repo ${{ github.repository }} \
            --token ${{ secrets.GITHUB_TOKEN }}

      - name: Commit and push if changelog changed
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add docs/changelog.rst docs/credits.rst
          if git diff --cached --quiet; then
            echo "No changes, skipping commit"
          else
            git commit -m "Update changelog for PR #${{ github.event.issue.number }}"
            HEAD_REPO="${{ steps.pr-info.outputs.head_repo }}"
            HEAD_BRANCH="${{ steps.pr-info.outputs.branch }}"
            PUSH_URL="https://x-access-token:${GH_TOKEN}@github.com/${HEAD_REPO}.git"
            git push "$PUSH_URL" "HEAD:refs/heads/${HEAD_BRANCH}"
          fi


================================================
FILE: .github/workflows/issues.py
================================================
#!/usr/bin/env python3

# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Bot triggered by Github Actions every time a new issue, PR or comment
is created. Assign labels, provide replies, closes issues, etc. depending
on the situation.
"""

import functools
import json
import os
import pathlib
import re
from pprint import pprint as pp

from github import Github

ROOT_DIR = pathlib.Path(__file__).resolve().parent.parent.parent
SCRIPTS_DIR = ROOT_DIR / 'scripts'


# --- constants

# fmt: off
LABELS_MAP = {
    # platforms
    "linux": [
        "linux", "ubuntu", "redhat", "mint", "centos", "red hat", "archlinux",
        "debian", "alpine", "gentoo", "fedora", "slackware", "suse", "RHEL",
        "opensuse", "manylinux", "apt ", "apt-", "rpm", "yum", "kali",
        "/sys/class", "/proc/net", "/proc/disk", "/proc/smaps",
        "/proc/vmstat",
    ],
    "windows": [
        "windows", "win32", "WinError", "WindowsError", "win10", "win7",
        "win ", "mingw", "msys", "studio", "microsoft",
        "CloseHandle", "GetLastError", "NtQuery", "DLL", "MSVC", "TCHAR",
        "WCHAR", ".bat", "OpenProcess", "TerminateProcess",
        "windows error", "NtWow64", "NTSTATUS", "Visual Studio",
    ],
    "macos": [
        "macos", "mac ", "osx", "os x", "mojave", "sierra", "capitan",
        "yosemite", "catalina", "mojave", "big sur", "xcode", "darwin",
        "dylib", "m1",
    ],
    "aix": ["aix"],
    "cygwin": ["cygwin"],
    "freebsd": ["freebsd"],
    "netbsd": ["netbsd"],
    "openbsd": ["openbsd"],
    "sunos": ["sunos", "solaris"],
    "wsl": ["wsl"],
    "unix": [
        "psposix", "waitpid", "statvfs", "/dev/tty",
        "/dev/pts", "posix",
    ],
    "pypy": ["pypy"],
    "docker": ["docker", "docker-compose"],
    "vm": [
        "docker", "docker-compose", "vmware", "lxc", "hyperv", "virtualpc",
        "virtualbox", "bhyve", "openvz", "lxc", "xen", "kvm", "qemu", "heroku",
    ],
    # types
    "enhancement": ["enhancement"],
    "memleak": ["memory leak", "leaks memory", "memleak", "mem leak"],
    "api": ["idea", "proposal", "api", "feature"],
    "performance": ["performance", "speedup", "speed up", "slow", "fast"],
    "wheels": ["wheel", "wheels"],
    "scripts": [
        "example script", "examples script", "example dir", "scripts/",
    ],
    # bug
    "bug": [
        "fail", "can't execute", "can't install", "cannot execute",
        "cannot install", "install error", "crash", "critical",
    ],
    # doc
    "doc": [
        "doc ", "document ", "documentation", "readthedocs", "pythonhosted",
        "HISTORY", "README", "dev guide", "devguide", "sphinx", "docfix",
        "index.rst",
    ],
    # tests
    "tests": [
        " test ", "tests", "travis", "coverage", "cirrus",
        "continuous integration", "unittest", "pytest", "unit test",
    ],
    # critical errors
    "critical": [
        "WinError", "WindowsError", "RuntimeError", "ZeroDivisionError",
        "SystemError", "MemoryError", "core dump", "segfault",
        "segmentation fault",
    ],
}

OS_LABELS = [
    "linux", "windows", "macos", "freebsd", "openbsd", "netbsd", "openbsd",
    "bsd", "sunos", "unix", "wsl", "aix", "cygwin",
]
# fmt: on

LABELS_MAP['scripts'].extend(
    [x for x in os.listdir(SCRIPTS_DIR) if x.endswith('.py')]
)

ILLOGICAL_PAIRS = [
    ('bug', 'enhancement'),
    ('doc', 'tests'),
    ('scripts', 'doc'),
    ('scripts', 'tests'),
    ('bsd', 'freebsd'),
    ('bsd', 'openbsd'),
    ('bsd', 'netbsd'),
]

# --- replies

REPLY_MISSING_PYTHON_HEADERS = """\
It looks like you're missing `Python.h` headers. This usually means you have \
to install them first, then retry psutil installation.
Please read \
[install](https://psutil.readthedocs.io/install) \
instructions for your platform. \
This is an auto-generated response based on the text you submitted. \
If this was a mistake or you think there's a bug with psutil installation \
process, please add a comment to reopen this issue.
"""

# REPLY_UPDATE_CHANGELOG = """\
# """


# --- github API utils


def is_pr(issue):
    return issue.pull_request is not None


def has_label(issue, label):
    assigned = [x.name for x in issue.labels]
    return label in assigned


def get_repo():
    repo = os.environ['GITHUB_REPOSITORY']
    token = os.environ['GITHUB_TOKEN']
    return Github(token).get_repo(repo)


# --- event utils


@functools.lru_cache()
def _get_event_data():
    with open(os.environ["GITHUB_EVENT_PATH"]) as f:
        ret = json.load(f)
        pp(ret)
        return ret


def is_event_new_issue():
    data = _get_event_data()
    try:
        return data['action'] == 'opened' and 'issue' in data
    except KeyError:
        return False


def is_event_new_pr():
    data = _get_event_data()
    try:
        return data['action'] == 'opened' and 'pull_request' in data
    except KeyError:
        return False


def get_issue():
    data = _get_event_data()
    try:
        num = data['issue']['number']
    except KeyError:
        num = data['pull_request']['number']
    return get_repo().get_issue(number=num)


# --- actions


def log(msg):
    if '\n' in msg or "\r\n" in msg:
        print(f">>>\n{msg}\n<<<", flush=True)
    else:
        print(f">>> {msg} <<<", flush=True)


def add_label(issue, label):
    def should_add(issue, label):
        if has_label(issue, label):
            log(f"already has label {label!r}")
            return False

        for left, right in ILLOGICAL_PAIRS:
            if label == left and has_label(issue, right):
                log(f"already has label f{label}")
                return False

        return not has_label(issue, label)

    if not should_add(issue, label):
        log(f"should not add label {label!r}")
        return

    log(f"add label {label!r}")
    issue.add_to_labels(label)


def _guess_labels_from_text(text):
    assert isinstance(text, str), text
    for label, keywords in LABELS_MAP.items():
        for keyword in keywords:
            if keyword.lower() in text.lower():
                yield (label, keyword)


def add_labels_from_text(issue, text):
    assert isinstance(text, str), text
    for label, keyword in _guess_labels_from_text(text):
        add_label(issue, label)


def add_labels_from_new_body(issue, text):
    assert isinstance(text, str), text
    log("start searching for template lines in new issue/PR body")
    # add os label
    r = re.search(r"\* OS:.*?\n", text)
    log("search for 'OS: ...' line")
    if r:
        log("found")
        add_labels_from_text(issue, r.group(0))
    else:
        log("not found")

    # add bug/enhancement label
    log("search for 'Bug fix: y/n' line")
    r = re.search(r"\* Bug fix:.*?\n", text)
    if (
        is_pr(issue)
        and r is not None
        and not has_label(issue, "bug")
        and not has_label(issue, "enhancement")
    ):
        log("found")
        s = r.group(0).lower()
        if 'yes' in s:
            add_label(issue, 'bug')
        else:
            add_label(issue, 'enhancement')
    else:
        log("not found")

    # add type labels
    log("search for 'Type: ...' line")
    r = re.search(r"\* Type:.*?\n", text)
    if r:
        log("found")
        s = r.group(0).lower()
        if 'doc' in s:
            add_label(issue, 'doc')
        if 'performance' in s:
            add_label(issue, 'performance')
        if 'scripts' in s:
            add_label(issue, 'scripts')
        if 'tests' in s:
            add_label(issue, 'tests')
        if 'wheels' in s:
            add_label(issue, 'wheels')
        if 'new-api' in s:
            add_label(issue, 'new-api')
        if 'new-platform' in s:
            add_label(issue, 'new-platform')
    else:
        log("not found")


# --- events


def on_new_issue(issue):
    def has_text(text):
        return text in issue.title.lower() or (
            issue.body and text in issue.body.lower()
        )

    def body_mentions_python_h():
        if not issue.body:
            return False
        body = issue.body.replace(' ', '')
        return (
            "#include<Python.h>\n^~~~" in body
            or "#include<Python.h>\r\n^~~~" in body
        )

    log("searching for missing Python.h")
    if (
        has_text("missing python.h")
        or has_text("python.h: no such file or directory")
        or body_mentions_python_h()
    ):
        log("found mention of Python.h")
        issue.create_comment(REPLY_MISSING_PYTHON_HEADERS)
        issue.edit(state='closed')
        return


def on_new_pr(issue):
    pass
    # pr = get_repo().get_pull(issue.number)
    # files = [x.filename for x in list(pr.get_files())]
    # if "changelog.rst" not in files:
    #     issue.create_comment(REPLY_UPDATE_CHANGELOG)


def main():
    issue = get_issue()
    stype = "PR" if is_pr(issue) else "issue"
    log(f"running issue bot for {stype} {issue!r}")

    if is_event_new_issue():
        log(f"created new issue {issue}")
        add_labels_from_text(issue, issue.title)
        if issue.body:
            add_labels_from_new_body(issue, issue.body)
        on_new_issue(issue)
    elif is_event_new_pr():
        log(f"created new PR {issue}")
        add_labels_from_text(issue, issue.title)
        if issue.body:
            add_labels_from_new_body(issue, issue.body)
        on_new_pr(issue)
    else:
        log("unhandled event")


if __name__ == '__main__':
    main()


================================================
FILE: .github/workflows/issues.yml
================================================
# Fired by Github Actions every time an issue, PR or comment is created.

name: issues
on:
  issues:
    types: [opened]
  pull_request_target:
    types: [opened]
  issue_comment:
    types: [created]
permissions:
  issues: write
  pull-requests: write
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Install Python
        uses: actions/setup-python@v6
        with:
          python-version: "3.x"

      - name: Install deps
        run: python3 -m pip install PyGithub

      - name: Run
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          PYTHONUNBUFFERED=1 PYTHONWARNINGS=always python3 .github/workflows/issues.py


================================================
FILE: .github/workflows/sunos.yml
================================================
# Execute tests on SunOS
# https://github.com/vmactions/solaris-vm

name: sunos
on:
  push:
    # only run this job if the following files are modified
    paths: &sunos_paths
      - ".github/workflows/sunos.yml"
      - "psutil/_pssunos.py"
      - "psutil/_psutil_sunos.c"
      - "psutil/arch/all/**"
      - "psutil/arch/posix/**"
      - "psutil/arch/sunos/**"
      - "setup.py"
  pull_request:
    paths: *sunos_paths
concurrency:
  group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && github.sha || '' }}
  cancel-in-progress: true
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Run tests
        id: test
        uses: vmactions/solaris-vm@v1
        with:
          release: "11.4-gcc"
          usesh: true
          run: |
            set -x
            python3 setup.py build_ext -i --parallel 4
            python3 -c "import psutil"
            python3 scripts/internal/install_pip.py
            python3 -m pip install --break-system-packages --user .[test]
            PYTHONMALLOC=malloc PYTHONUNBUFFERED=1 python3 -m pytest tests/test_memleaks.py


================================================
FILE: .gitignore
================================================
syntax: glob
*.al
*.bak
*.egg-info
*.la
*.lo
*.o
*.orig
*.pyc
*.pyd
*.rej
*.so
*.swp
.failed-tests.txt
.cache/
.idea/
.tox/
build/
docs/_build/
dist/
wheelhouse/
.tests/


================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to psutil project

## Issues

- The issue tracker is for reporting problems or proposing enhancements related
  to the **program code**.
- Please do not open issues **asking for support**. Instead, use the forum at:
  https://groups.google.com/g/psutil.
- Before submitting a new issue, **search** if there are existing issues for
  the same topic.
- **Be clear** in describing what the problem is and try to be accurate in
  editing the default issue **template**. There is a bot which automatically
  assigns **labels** based on issue's title and body format. Labels help
  keeping the issues properly organized and searchable (by OS, issue type,
  etc.).
- When reporting a malfunction, consider enabling
  [debug mode](https://psutil.readthedocs.io/en/latest/#debug-mode) first.
- To report a **security vulnerability**, use the
  [Tidelift security contact](https://tidelift.com/security). Tidelift will
  coordinate the fix and the disclosure of the reported problem.

## Pull Requests

- The PR system is for fixing bugs or make enhancements related to the
  **program code**.
- If you wish to implement a new feature or add support for a new platform it's
  better to **discuss it first**, either on the issue tracker, the forum or via
  private email.
- In order to get acquainted with the code base and tooling, take a look at the
  **[Development Guide](https://psutil.readthedocs.io/devguide)**.
- If you can, remember to update
  [changelog.rst](https://github.com/giampaolo/psutil/blob/master/docs/changelog.rst)
  and [CREDITS](https://github.com/giampaolo/psutil/blob/master/CREDITS) file.


================================================
FILE: HISTORY.rst
================================================
History has moved to:

- https://psutil.readthedocs.io/changelog
- https://github.com/giampaolo/psutil/blob/master/docs/changelog.rst (source)


================================================
FILE: INSTALL.rst
================================================
Installation instructions have moved to:

- https://psutil.readthedocs.io/install
- https://github.com/giampaolo/psutil/blob/master/docs/install.rst (source)


================================================
FILE: LICENSE
================================================
BSD 3-Clause License

Copyright (c) 2009, Jay Loden, Dave Daeschler, Giampaolo Rodola
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

 * Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

 * Neither the name of the psutil authors nor the names of its contributors
   may be used to endorse or promote products derived from this software without
   specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


================================================
FILE: MANIFEST.in
================================================
include .clang-format
include .dprint.jsonc
include .gitignore
include CONTRIBUTING.md
include HISTORY.rst
include INSTALL.rst
include LICENSE
include MANIFEST.in
include Makefile
include README.rst
include SECURITY.md
include _bootstrap.py
include docs/.readthedocs.yaml
include docs/DEVNOTES
include docs/Makefile
include docs/README
include docs/_ext/add_home_link.py
include docs/_ext/availability.py
include docs/_ext/changelog_anchors.py
include docs/_ext/check_python_syntax.py
include docs/_links.rst
include docs/_static/copybutton.js
include docs/_static/css/custom.css
include docs/_static/favicon.ico
include docs/_static/sidebar.js
include docs/_templates/layout.html
include docs/adoption.rst
include docs/alternatives.rst
include docs/api.rst
include docs/changelog.rst
include docs/conf.py
include docs/credits.rst
include docs/devguide.rst
include docs/faq.rst
include docs/glossary.rst
include docs/index.rst
include docs/install.rst
include docs/migration.rst
include docs/platform.rst
include docs/recipes.rst
include docs/requirements.txt
include docs/shell_equivalents.rst
include docs/timeline.rst
include psutil/__init__.py
include psutil/_common.py
include psutil/_enums.py
include psutil/_ntuples.py
include psutil/_psaix.py
include psutil/_psbsd.py
include psutil/_pslinux.py
include psutil/_psosx.py
include psutil/_psposix.py
include psutil/_pssunos.py
include psutil/_psutil_aix.c
include psutil/_psutil_bsd.c
include psutil/_psutil_linux.c
include psutil/_psutil_osx.c
include psutil/_psutil_sunos.c
include psutil/_psutil_windows.c
include psutil/_pswindows.py
include psutil/arch/aix/common.c
include psutil/arch/aix/common.h
include psutil/arch/aix/ifaddrs.c
include psutil/arch/aix/ifaddrs.h
include psutil/arch/aix/net_connections.c
include psutil/arch/aix/net_connections.h
include psutil/arch/aix/net_kernel_structs.h
include psutil/arch/all/errors.c
include psutil/arch/all/init.c
include psutil/arch/all/init.h
include psutil/arch/all/pids.c
include psutil/arch/all/str.c
include psutil/arch/all/utils.c
include psutil/arch/bsd/cpu.c
include psutil/arch/bsd/disk.c
include psutil/arch/bsd/heap.c
include psutil/arch/bsd/init.c
include psutil/arch/bsd/init.h
include psutil/arch/bsd/mem.c
include psutil/arch/bsd/net.c
include psutil/arch/bsd/proc.c
include psutil/arch/bsd/proc_utils.c
include psutil/arch/bsd/sys.c
include psutil/arch/freebsd/cpu.c
include psutil/arch/freebsd/disk.c
include psutil/arch/freebsd/init.h
include psutil/arch/freebsd/mem.c
include psutil/arch/freebsd/pids.c
include psutil/arch/freebsd/proc.c
include psutil/arch/freebsd/proc_socks.c
include psutil/arch/freebsd/sensors.c
include psutil/arch/freebsd/sys_socks.c
include psutil/arch/linux/disk.c
include psutil/arch/linux/heap.c
include psutil/arch/linux/init.h
include psutil/arch/linux/mem.c
include psutil/arch/linux/net.c
include psutil/arch/linux/proc.c
include psutil/arch/netbsd/cpu.c
include psutil/arch/netbsd/disk.c
include psutil/arch/netbsd/init.h
include psutil/arch/netbsd/mem.c
include psutil/arch/netbsd/pids.c
include psutil/arch/netbsd/proc.c
include psutil/arch/netbsd/socks.c
include psutil/arch/openbsd/cpu.c
include psutil/arch/openbsd/disk.c
include psutil/arch/openbsd/init.h
include psutil/arch/openbsd/mem.c
include psutil/arch/openbsd/pids.c
include psutil/arch/openbsd/proc.c
include psutil/arch/openbsd/socks.c
include psutil/arch/openbsd/users.c
include psutil/arch/osx/cpu.c
include psutil/arch/osx/disk.c
include psutil/arch/osx/heap.c
include psutil/arch/osx/init.c
include psutil/arch/osx/init.h
include psutil/arch/osx/mem.c
include psutil/arch/osx/net.c
include psutil/arch/osx/pids.c
include psutil/arch/osx/proc.c
include psutil/arch/osx/proc_utils.c
include psutil/arch/osx/sensors.c
include psutil/arch/osx/sys.c
include psutil/arch/posix/init.c
include psutil/arch/posix/init.h
include psutil/arch/posix/net.c
include psutil/arch/posix/pids.c
include psutil/arch/posix/proc.c
include psutil/arch/posix/sysctl.c
include psutil/arch/posix/users.c
include psutil/arch/sunos/cpu.c
include psutil/arch/sunos/disk.c
include psutil/arch/sunos/environ.c
include psutil/arch/sunos/init.h
include psutil/arch/sunos/mem.c
include psutil/arch/sunos/net.c
include psutil/arch/sunos/proc.c
include psutil/arch/sunos/sys.c
include psutil/arch/windows/cpu.c
include psutil/arch/windows/disk.c
include psutil/arch/windows/heap.c
include psutil/arch/windows/init.c
include psutil/arch/windows/init.h
include psutil/arch/windows/mem.c
include psutil/arch/windows/net.c
include psutil/arch/windows/ntextapi.h
include psutil/arch/windows/pids.c
include psutil/arch/windows/proc.c
include psutil/arch/windows/proc_handles.c
include psutil/arch/windows/proc_info.c
include psutil/arch/windows/proc_utils.c
include psutil/arch/windows/security.c
include psutil/arch/windows/sensors.c
include psutil/arch/windows/services.c
include psutil/arch/windows/socks.c
include psutil/arch/windows/sys.c
include psutil/arch/windows/wmi.c
include pyproject.toml
include scripts/battery.py
include scripts/cpu_distribution.py
include scripts/disk_usage.py
include scripts/fans.py
include scripts/free.py
include scripts/ifconfig.py
include scripts/internal/README
include scripts/internal/bench_oneshot.py
include scripts/internal/bench_oneshot_2.py
include scripts/internal/convert_readme.py
include scripts/internal/download_wheels.py
include scripts/internal/find_adopters.py
include scripts/internal/find_broken_links.py
include scripts/internal/generate_manifest.py
include scripts/internal/git_pre_commit.py
include scripts/internal/install-sysdeps.sh
include scripts/internal/install_pip.py
include scripts/internal/print_access_denied.py
include scripts/internal/print_announce.py
include scripts/internal/print_api_speed.py
include scripts/internal/print_dist.py
include scripts/internal/print_downloads.py
include scripts/internal/print_hashes.py
include scripts/internal/print_sysinfo.py
include scripts/internal/purge_installation.py
include scripts/internal/rst_check_dead_refs.py
include scripts/iotop.py
include scripts/killall.py
include scripts/meminfo.py
include scripts/netstat.py
include scripts/nettop.py
include scripts/pidof.py
include scripts/pmap.py
include scripts/procinfo.py
include scripts/procsmem.py
include scripts/ps.py
include scripts/pstree.py
include scripts/sensors.py
include scripts/temperatures.py
include scripts/top.py
include scripts/who.py
include scripts/winservices.py
include setup.py
include tests/README.md
include tests/__init__.py
include tests/test_aix.py
include tests/test_bsd.py
include tests/test_connections.py
include tests/test_contracts.py
include tests/test_heap.py
include tests/test_linux.py
include tests/test_memleaks.py
include tests/test_misc.py
include tests/test_osx.py
include tests/test_posix.py
include tests/test_process.py
include tests/test_process_all.py
include tests/test_scripts.py
include tests/test_sudo.py
include tests/test_sunos.py
include tests/test_system.py
include tests/test_testutils.py
include tests/test_type_hints.py
include tests/test_unicode.py
include tests/test_windows.py
recursive-exclude docs/_static *


================================================
FILE: Makefile
================================================
# Shortcuts for various development tasks.
#
# - To use this on Windows install Git For Windows first, then launch a Git
#   Bash Shell.
# - To use a specific Python version run: `make install PYTHON=python3.3`.
# - To append an argument to a command use ARGS, e.g: `make test ARGS="-k
#   some_test`.

# Configurable
PYTHON = python3
ARGS =
FILES =

PIP_INSTALL_ARGS = --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade --upgrade-strategy eager
PYTHON_ENV_VARS = PYTHONWARNINGS=always PYTHONUNBUFFERED=1 PSUTIL_DEBUG=1 PSUTIL_TESTING=1 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
SUDO = $(if $(filter $(OS),Windows_NT),,sudo -E)
DPRINT = ~/.dprint/bin/dprint

# if make is invoked with no arg, default to `make help`
.DEFAULT_GOAL := help

# install git hook
_ := $(shell mkdir -p .git/hooks/ && ln -sf ../../scripts/internal/git_pre_commit.py .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit)

# ===================================================================
# Install
# ===================================================================

clean:  ## Remove all build files.
	@rm -rfv `find . \
		-type d -name __pycache__ \
		-o -type f -name \*.bak \
		-o -type f -name \*.orig \
		-o -type f -name \*.pyc \
		-o -type f -name \*.pyd \
		-o -type f -name \*.pyo \
		-o -type f -name \*.rej \
		-o -type f -name \*.so \
		-o -type f -name \*.~ \
		-o -type f -name \*\$testfn`
	@rm -rfv \
		*.core \
		*.egg-info \
		*\@psutil-* \
		.coverage \
		.failed-tests.txt \
		.pytest_cache \
		.ruff_cache/ \
		.tests \
		build/ \
		dist/ \
		docs/_build/ \
		htmlcov/ \
		pytest-cache-files* \
		wheelhouse

.PHONY: build
build:  ## Compile (in parallel) without installing.
	@# "build_ext -i" copies compiled *.so files in ./psutil directory in order
	@# to allow "import psutil" when using the interactive interpreter from
	@# within  this directory.
	$(PYTHON_ENV_VARS) $(PYTHON) setup.py build_ext -i --parallel 4
	$(PYTHON_ENV_VARS) $(PYTHON) -c "import psutil"  # make sure it actually worked

install:  ## Install this package as current user in "edit" mode.
	$(MAKE) build
	# If not in a virtualenv, add --user to the install command.
	$(PYTHON_ENV_VARS) $(PYTHON) setup.py develop $(SETUP_INSTALL_ARGS) `$(PYTHON) -c \
		"import sys; print('' if hasattr(sys, 'real_prefix') or hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix else '--user')"`

uninstall:  ## Uninstall this package via pip.
	cd ..; $(PYTHON_ENV_VARS) $(PYTHON) -m pip uninstall -y -v psutil || true
	$(PYTHON_ENV_VARS) $(PYTHON) scripts/internal/purge_installation.py

install-pip:  ## Install pip (no-op if already installed).
	$(PYTHON) scripts/internal/install_pip.py

install-sysdeps:
	./scripts/internal/install-sysdeps.sh

install-pydeps-test:  ## Install python deps necessary to run unit tests.
	$(MAKE) install-pip
	PIP_BREAK_SYSTEM_PACKAGES=1 $(PYTHON) -m pip install $(PIP_INSTALL_ARGS) setuptools
	PIP_BREAK_SYSTEM_PACKAGES=1 $(PYTHON) -m pip install $(PIP_INSTALL_ARGS) .[test]

install-pydeps-lint:  ## Install python deps necessary to run linters.
	$(MAKE) install-pip
	PIP_BREAK_SYSTEM_PACKAGES=1 $(PYTHON) -m pip install $(PIP_INSTALL_ARGS) setuptools
	PIP_BREAK_SYSTEM_PACKAGES=1 $(PYTHON) -m pip install $(PIP_INSTALL_ARGS) .[lint]

install-pydeps-dev:  ## Install python deps meant for local development.
	$(MAKE) install-pip
	PIP_BREAK_SYSTEM_PACKAGES=1 $(PYTHON) -m pip install $(PIP_INSTALL_ARGS) setuptools
	PIP_BREAK_SYSTEM_PACKAGES=1 $(PYTHON) -m pip install $(PIP_INSTALL_ARGS) .[dev]

# ===================================================================
# Tests
# ===================================================================

# Cache dir on Windows often causes "Permission denied" errors
_PYTEST_EXTRA != if [ "$$OS" = "Windows_NT" ]; then printf '%s' '-o cache_dir=/tmp/pytest-psutil-cache'; fi
RUN_TEST = $(PYTHON_ENV_VARS) $(PYTHON) -m pytest $(_PYTEST_EXTRA)

test:  ## Run all tests (except memleak tests).
	# To run a specific test do `make test ARGS=tests/test_process.py::TestProcess::test_cmdline`
	$(RUN_TEST) $(ARGS)

test-parallel:  ## Run all tests (except memleak tests) in parallel.
	$(RUN_TEST) -p xdist -n auto --dist loadgroup $(ARGS)

test-process:  ## Run process-related tests.
	$(RUN_TEST) -k "test_process.py or test_proc or test_pid or Process or pids or pid_exists" $(ARGS)

test-process-all:  ## Run tests which iterate over all process PIDs.
	$(RUN_TEST) -k test_process_all.py $(ARGS)

test-system:  ## Run system-related API tests.
	$(RUN_TEST) -k "test_system.py or test_sys or System or disk or sensors or net_io_counters or net_if_addrs or net_if_stats or users or pids or win_service_ or boot_time" $(ARGS)

test-misc:  ## Run miscellaneous tests.
	$(RUN_TEST) -k "test_misc.py or Misc" $(ARGS)

test-scripts:  ## Run scripts tests.
	$(RUN_TEST) tests/test_scripts.py $(ARGS)

test-testutils:  ## Run test utils tests.
	$(RUN_TEST) tests/test_testutils.py $(ARGS)

test-unicode:  ## Test APIs dealing with strings.
	$(RUN_TEST) tests/test_unicode.py $(ARGS)

test-contracts:  ## APIs sanity tests.
	$(RUN_TEST) tests/test_contracts.py $(ARGS)

test-type-hints:  ## Test type hints
	$(RUN_TEST) tests/test_type_hints.py $(ARGS)

test-connections:  ## Test psutil.net_connections() and Process.net_connections().
	$(RUN_TEST) -k "test_connections.py or net_" $(ARGS)

test-heap:  ## Test psutil.heap_*() APIs.
	$(RUN_TEST) -k "test_heap.py or heap_" $(ARGS)

test-posix:  ## POSIX specific tests.
	$(RUN_TEST) -k "test_posix.py or posix_ or Posix" $(ARGS)

test-platform:  ## Run specific platform tests only.
	$(RUN_TEST) -k test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py $(ARGS)

test-memleaks:  ## Memory leak tests.
	PYTHONMALLOC=malloc $(RUN_TEST) -k test_memleaks.py $(ARGS)

test-sudo:  ## Run tests requiring root privileges.
	# Use unittest runner because pytest may not be installed as root.
	$(SUDO) $(PYTHON_ENV_VARS) $(PYTHON) -m unittest -v tests.test_sudo

test-last-failed:  ## Re-run tests which failed on last run
	$(RUN_TEST) --last-failed $(ARGS)

coverage:  ## Run test coverage.
	rm -rf .coverage htmlcov
	$(PYTHON_ENV_VARS) $(PYTHON) -m coverage run -m pytest $(ARGS)
	$(PYTHON) -m coverage report
	@echo "writing results to htmlcov/index.html"
	$(PYTHON) -m coverage html
	$(PYTHON) -m webbrowser -t htmlcov/index.html

# ===================================================================
# Linters
# ===================================================================

# Return a shell pipeline that outputs one file per line. Uses
# $(FILES) if set, else "git ls-files" with given pattern(s).
_ls = $(if $(FILES), printf '%s\n' $(FILES), git ls-files $(1))

ruff:  ## Run ruff linter.
	@$(call _ls,'*.py') | xargs $(PYTHON) -m ruff check --output-format=concise

black:  ## Run black formatter.
	@$(call _ls,'*.py') | xargs $(PYTHON) -m black --check --safe

lint-c:  ## Run C linter.
	@$(call _ls,'*.c' '*.h') | xargs -P0 -I{} clang-format --dry-run --Werror {}

dprint:
	@$(DPRINT) check

lint-rst:  ## Run linter for .rst files.
	@$(call _ls,'*.rst') | xargs python3 scripts/internal/rst_check_dead_refs.py
	@$(call _ls,'*.rst') | xargs sphinx-lint

lint-toml:  ## Run linter for pyproject.toml.
	@$(call _ls,'*.toml') | xargs toml-sort --check

lint-all:  ## Run all linters
	$(MAKE) black
	$(MAKE) ruff
	$(MAKE) lint-c
	$(MAKE) dprint
	$(MAKE) lint-rst
	$(MAKE) lint-toml

# --- not mandatory linters (just run from time to time)

pylint:  ## Python pylint
	@git ls-files '*.py' | xargs $(PYTHON) -m pylint --rcfile=pyproject.toml --jobs=0 $(ARGS)

vulture:  ## Find unused code
	@git ls-files '*.py' | xargs $(PYTHON) -m vulture $(ARGS)

# ===================================================================
# Fixers
# ===================================================================

fix-black:
	@git ls-files '*.py' | xargs $(PYTHON) -m black

fix-ruff:
	@git ls-files '*.py' | xargs $(PYTHON) -m ruff check --fix --output-format=concise $(ARGS)

fix-c:
	@git ls-files '*.c' '*.h' | xargs -P0 -I{} clang-format -i {}  # parallel exec

fix-toml:  ## Fix pyproject.toml
	@git ls-files '*.toml' | xargs toml-sort

fix-dprint:
	@$(DPRINT) fmt

fix-all:  ## Run all code fixers.
	$(MAKE) fix-ruff
	$(MAKE) fix-black
	$(MAKE) fix-toml
	$(MAKE) fix-dprint

# ===================================================================
# CI jobs
# ===================================================================

ci-lint:  ## Run all linters on GitHub CI.
	$(MAKE) install-pydeps-lint
	curl -fsSL https://dprint.dev/install.sh | sh
	$(DPRINT) --version
	clang-format --version
	$(MAKE) lint-all

ci-test:  ## Run tests on GitHub CI. Used by BSD runners.
	$(MAKE) install-sysdeps
	$(MAKE) install-pydeps-test
	$(MAKE) build
	$(MAKE) print-sysinfo
	$(MAKE) test
	$(MAKE) test-memleaks

ci-test-cibuildwheel:  ## Run CI tests for the built wheels.
	$(MAKE) install-sysdeps
	$(MAKE) install-pydeps-test
	$(MAKE) print-sysinfo
	# Tests must be run from a separate directory so pytest does not import
	# from the source tree and instead exercises only the installed wheel.
	rm -rf .tests tests/__pycache__
	mkdir -p .tests
	cp -r tests .tests/
	cd .tests/ && PYTHONPATH=$$(pwd) $(PYTHON_ENV_VARS) $(PYTHON) -m pytest
	cd .tests/ && PYTHONPATH=$$(pwd) $(PYTHON_ENV_VARS) PYTHONMALLOC=malloc $(PYTHON) -m pytest -k test_memleaks.py

ci-check-dist:  ## Run all sanity checks re. to the package distribution.
	$(PYTHON) -m pip install -U setuptools virtualenv twine check-manifest validate-pyproject[all] abi3audit
	$(MAKE) create-sdist
	mv wheelhouse/* dist/
	$(MAKE) check-dist
	$(MAKE) install
	$(MAKE) print-dist

# ===================================================================
# Distribution
# ===================================================================

# --- create

generate-manifest:  ## Generates MANIFEST.in file.
	$(PYTHON) scripts/internal/generate_manifest.py > MANIFEST.in

create-sdist:  ## Create tar.gz source distribution.
	$(MAKE) generate-manifest
	$(PYTHON_ENV_VARS) $(PYTHON) setup.py sdist

create-wheels:  ## Create .whl files
	$(PYTHON_ENV_VARS) $(PYTHON) setup.py bdist_wheel

download-wheels:  ## Download latest wheels hosted on github.
	$(PYTHON) scripts/internal/download_wheels.py --tokenfile=~/.github.token
	$(MAKE) print-dist

create-dist:  ## Create .tar.gz + .whl distribution.
	$(MAKE) create-sdist
	$(MAKE) download-wheels

# --- check

check-manifest:  ## Check sanity of MANIFEST.in file.
	$(PYTHON) -m check_manifest -v

check-pyproject:  ## Check sanity of pyproject.toml file.
	$(PYTHON) -m validate_pyproject -v pyproject.toml

check-sdist:  ## Check sanity of source distribution.
	$(PYTHON_ENV_VARS) $(PYTHON) -m virtualenv --clear --no-wheel --quiet build/venv
	$(PYTHON_ENV_VARS) build/venv/bin/python -m pip install -v --isolated --quiet dist/*.tar.gz
	$(PYTHON_ENV_VARS) build/venv/bin/python -c "import os; os.chdir('build/venv'); import psutil"
	$(PYTHON) -m twine check --strict dist/*.tar.gz

check-wheels:  ## Check sanity of wheels.
	$(PYTHON) -m abi3audit --verbose --strict dist/*-abi3-*.whl
	$(PYTHON) -m twine check --strict dist/*.whl

check-dist:  ## Run all sanity checks re. to the package distribution.
	$(MAKE) check-manifest
	$(MAKE) check-pyproject
	$(MAKE) check-sdist
	$(MAKE) check-wheels

# --- release

pre-release:  ## Check if we're ready to produce a new release.
	$(MAKE) clean
	$(MAKE) create-dist
	$(MAKE) check-dist
	$(MAKE) install
	@$(PYTHON) -c \
		"import requests, sys; \
		from packaging.version import parse; \
		from psutil import __version__; \
		res = requests.get('https://pypi.org/pypi/psutil/json', timeout=5); \
		versions = sorted(res.json()['releases'], key=parse, reverse=True); \
		sys.exit('version %r already exists on PYPI' % __version__) if __version__ in versions else 0"
	@ver=$$($(PYTHON) -c "from psutil import __version__; print(__version__)"); \
		grep -q "$$ver" docs/changelog.rst || { echo "ERR: version $$ver not found in docs/changelog.rst"; exit 1; }; \
		grep -q "$$ver" docs/timeline.rst || { echo "ERR: version $$ver not found in docs/timeline.rst"; exit 1; }
	$(MAKE) print-hashes
	$(MAKE) print-dist

release:  ## Upload a new release.
	$(PYTHON) -m twine upload dist/*.tar.gz
	$(PYTHON) -m twine upload dist/*.whl
	$(MAKE) git-tag-release

git-tag-release:  ## Git-tag a new release.
	git tag -a release-`python3 -c "import setup; print(setup.get_version())"` -m `git rev-list HEAD --count`:`git rev-parse --short HEAD`
	git push --follow-tags

# ===================================================================
# Printers
# ===================================================================

print-announce:  ## Print announce of new release.
	@$(PYTHON) scripts/internal/print_announce.py

print-access-denied: ## Print AD exceptions
	$(PYTHON) scripts/internal/print_access_denied.py

print-api-speed:  ## Benchmark all API calls
	$(PYTHON) scripts/internal/print_api_speed.py $(ARGS)

print-downloads:  ## Print PYPI download statistics
	$(PYTHON) scripts/internal/print_downloads.py

print-hashes:  ## Prints hashes of files in dist/ directory
	$(PYTHON) scripts/internal/print_hashes.py

print-sysinfo:  ## Prints system info
	$(PYTHON) scripts/internal/print_sysinfo.py

print-dist:  ## Print downloaded wheels / tar.gz
	$(PYTHON) scripts/internal/print_dist.py

# ===================================================================
# Misc
# ===================================================================

grep-todos:  ## Look for TODOs in the source files.
	git grep -EIn "TODO|FIXME|XXX"

bench-oneshot:  ## Benchmarks for oneshot() ctx manager (see #799).
	$(PYTHON) scripts/internal/bench_oneshot.py

bench-oneshot-2:  ## Same as above but using perf module (supposed to be more precise)
	$(PYTHON) scripts/internal/bench_oneshot_2.py

find-broken-links:  ## Look for broken links in source files.
	git ls-files | xargs $(PYTHON) -Wa scripts/internal/find_broken_links.py

help: ## Display callable targets.
	@awk -F':.*?## ' '/^[a-zA-Z0-9_.-]+:.*?## / {printf "\033[36m%-24s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort


================================================
FILE: README.rst
================================================
|  |downloads| |stars| |forks| |contributors| |packages|
|  |version| |license| |stackoverflow| |twitter| |tidelift|
|  |github-actions-wheels| |github-actions-bsd|

.. |downloads| image:: https://img.shields.io/pypi/dm/psutil.svg
    :target: https://clickpy.clickhouse.com/dashboard/psutil
    :alt: Downloads

.. |stars| image:: https://img.shields.io/github/stars/giampaolo/psutil.svg
    :target: https://github.com/giampaolo/psutil/stargazers
    :alt: Github stars

.. |forks| image:: https://img.shields.io/github/forks/giampaolo/psutil.svg
    :target: https://github.com/giampaolo/psutil/network/members
    :alt: Github forks

.. |contributors| image:: https://img.shields.io/github/contributors/giampaolo/psutil.svg
    :target: https://github.com/giampaolo/psutil/graphs/contributors
    :alt: Contributors

.. |stackoverflow| image:: https://img.shields.io/badge/stackoverflow-Ask%20questions-blue.svg
    :target: https://stackoverflow.com/questions/tagged/psutil
    :alt: Stackoverflow

.. |github-actions-wheels| image:: https://img.shields.io/github/actions/workflow/status/giampaolo/psutil/.github/workflows/build.yml.svg?label=Linux%2C%20macOS%2C%20Windows
    :target: https://github.com/giampaolo/psutil/actions?query=workflow%3Abuild
    :alt: Linux, macOS, Windows

.. |github-actions-bsd| image:: https://img.shields.io/github/actions/workflow/status/giampaolo/psutil/.github/workflows/bsd.yml.svg?label=BSD
    :target: https://github.com/giampaolo/psutil/actions?query=workflow%3Absd-tests
    :alt: FreeBSD, NetBSD, OpenBSD

.. |version| image:: https://img.shields.io/pypi/v/psutil.svg?label=pypi
    :target: https://pypi.org/project/psutil
    :alt: Latest version

.. |packages| image:: https://repology.org/badge/tiny-repos/python:psutil.svg
    :target: https://repology.org/metapackage/python:psutil/versions
    :alt: Binary packages

.. |license| image:: https://img.shields.io/pypi/l/psutil.svg
    :target: https://github.com/giampaolo/psutil/blob/master/LICENSE
    :alt: License

.. |twitter| image:: https://img.shields.io/twitter/follow/grodola?style=flat
    :target: https://twitter.com/grodola
    :alt: Twitter Follow

.. |tidelift| image:: https://tidelift.com/badges/github/giampaolo/psutil?style=flat
    :target: https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme
    :alt: Tidelift

-----

.. raw:: html

    <div align="center">
        <a href="https://github.com/giampaolo/psutil"><img src="https://github.com/giampaolo/psutil/raw/master/docs/_static/psutil-logo.png" /></a>
        <br />
        <br />
        <a href="https://github.com/giampaolo/psutil"><b>Home</b></a>&nbsp;&nbsp;&nbsp;
        <a href="https://psutil.readthedocs.io/"><b>Documentation</b></a>&nbsp;&nbsp;&nbsp;
        <a href="https://psutil.readthedocs.io/adoption"><b>Who uses psutil</b></a>&nbsp;&nbsp;&nbsp;
        <a href="https://pypi.org/project/psutil/#files"><b>Download</b></a>&nbsp;&nbsp;&nbsp;
        <a href="https://gmpy.dev/tags/psutil"><b>Blog</b></a>&nbsp;&nbsp;&nbsp;
        <a href="#funding"><b>Funding</b></a>&nbsp;&nbsp;&nbsp;
    </div>

Summary
=======

psutil (process and system utilities) is a cross-platform library for
retrieving information about **running processes** and **system utilization**
(CPU, memory, disks, network, sensors) in Python. It is useful mainly for
**system monitoring**, **profiling**, **limiting process resources**, and
**managing running processes**. It implements many functionalities offered by
classic UNIX command line tools such as
*ps, top, free, iotop, netstat, ifconfig, lsof*
and others (see `shell equivalents`_).
psutil currently supports the following platforms:

- **Linux**
- **Windows**
- **macOS**
- **FreeBSD, OpenBSD**, **NetBSD**
- **Sun Solaris**
- **AIX**

.. <PYPI-EXCLUDE>

Sponsors
========

.. raw:: html

    <table border="0" cellpadding="10" cellspacing="0">
      <tr>
        <td align="center">
          <a href="https://tidelift.com/subscription/pkg/pypi-psutil?utm_source=pypi-psutil&utm_medium=referral&utm_campaign=readme">
            <img width="200" src="https://github.com/giampaolo/psutil/raw/master/docs/_static/tidelift-logo.svg">
          </a>
        </td>
        <td align="center">
          <a href="https://sansec.io/">
            <img src="https://sansec.io/assets/images/logo.svg">
          </a>
        </td>
        <td align="center">
          <a href="https://www.apivoid.com/">
            <img width="180" src="https://gmpy.dev/images/apivoid-logo.svg">
          </a>
        </td>
      </tr>
    </table>

    <sup><a href="https://github.com/sponsors/giampaolo">add your logo</a></sup>

.. </PYPI-EXCLUDE>

Funding
=======

While psutil is free software and will always remain so, the project would benefit
immensely from some funding. psutil is among the `top 100`_ most-downloaded
Python packages, and keeping up with bug reports, user support, and ongoing
maintenance has become increasingly difficult to sustain as a one-person
effort. If you're a company that's making significant use of psutil you can
consider becoming a sponsor via `GitHub
<https://github.com/sponsors/giampaolo>`_, `Open Collective
<https://opencollective.com/psutil>`_ or `PayPal
<https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=A9ZS7PKKRM3S8>`_.
Sponsors can have their logo displayed here and in the psutil `documentation
<https://psutil.readthedocs.io>`_.

Projects using psutil
=====================

psutil is one of the `top 100`_ most-downloaded packages on PyPI, with 280+
million downloads per month, `760,000+ GitHub repositories
<https://github.com/giampaolo/psutil/network/dependents>`_ using it, and
14,000+ packages depending on it. Some notable projects using psutil:

- `TensorFlow <https://github.com/tensorflow/tensorflow>`_,
  `PyTorch <https://github.com/pytorch/pytorch>`_,
- `Home Assistant <https://github.com/home-assistant/core>`_,
  `Ansible <https://github.com/ansible/ansible>`_,
  `Apache Airflow <https://github.com/apache/airflow>`_,
  `Sentry <https://github.com/getsentry/sentry>`_
- `Celery <https://github.com/celery/celery>`_,
  `Dask <https://github.com/dask/dask>`_
- `Glances <https://github.com/nicolargo/glances>`_,
  `bpytop <https://github.com/aristocratos/bpytop>`_,
  `Ajenti <https://github.com/ajenti/ajenti>`_,
  `GRR <https://github.com/google/grr>`_
- `psleak`_

`Full list <https://psutil.readthedocs.io/adoption>`_



Ports
=====

- Go: `gopsutil <https://github.com/shirou/gopsutil>`_
- C: `cpslib <https://github.com/hamon-in/cpslib>`_
- Rust: `rust-psutil <https://github.com/rust-psutil/rust-psutil>`_
- Nim: `psutil-nim <https://github.com/johnscillieri/psutil-nim>`_

.. <PYPI-EXCLUDE>

Supporters
==========

People who donated money over the years:

.. raw:: html

    <div>
      <a href="https://github.com/codingjoe"><img height="35" width="35" title="Johannes Maron" src="https://avatars.githubusercontent.com/u/1772890?v=4" /></a>
      <a href="https://github.com/eallrich"><img height="35" width="35" title="Evan Allrich" src="https://avatars.githubusercontent.com/u/17393?v=4" /></a>
      <a href="https://github.com/ofek"><img height="35" width="35" title="Ofek Lev" src="https://avatars.githubusercontent.com/u/9677399?v=4" /></a>
      <a href="https://github.com/roboflow"><img height="35" width="35" title="roboflow.com" src="https://avatars.githubusercontent.com/u/53104118?s=200&v=4" /></a>
      <a href="https://github.com/sansecio"><img height="35" width="35" title="sansec.io" src="https://avatars.githubusercontent.com/u/60706188?s=200&v=4" /></a>
      <a href="https://github.com/Trash-Nothing"><img height="35" width="35" title="trashnothing.com" src="https://avatars.githubusercontent.com/u/230028908?s=200&v=4" /></a>

      <a href="https://github.com/abramov-v"><img height="35" width="35" title="Valeriy Abramov" src="https://avatars.githubusercontent.com/u/76448042?v=4" /></a>
      <a href="https://github.com/alexdlaird"><img height="35" width="35" title="Alex Laird" src="https://avatars.githubusercontent.com/u/1660326?v=4" /></a>
      <a href="https://github.com/aristocratos"><img height="35" width="35" title="aristocratos" src="https://avatars3.githubusercontent.com/u/59659483?s=96&amp;v=4" /></a>
      <a href="https://github.com/ArtyomVancyan"><img height="35" width="35" title="Artyom Vancyan" src="https://avatars.githubusercontent.com/u/44609997?v=4" /></a>
      <a href="https://github.com/c0m4r"><img height="35" width="35" title="c0m4r" src="https://avatars.githubusercontent.com/u/6292788?v=4" /></a>
      <a href="https://github.com/coskundeniz"><img height="35" width="35" title="Coşkun Deniz" src="https://avatars.githubusercontent.com/u/4516210?v=4" /></a>
      <a href="https://github.com/cybersecgeek"><img height="35" width="35" title="cybersecgeek" src="https://avatars.githubusercontent.com/u/12847926?v=4" /></a>
      <a href="https://github.com/dbwiddis"><img height="35" width="35" title="Daniel Widdis" src="https://avatars1.githubusercontent.com/u/9291703?s=88&amp;v=4" /></a>
      <a href="https://github.com/getsentry"><img height="35" width="35" title="getsentry" src="https://avatars.githubusercontent.com/u/1396951?s=200&v=4" /></a>
      <a href="https://github.com/great-work-told-is"><img height="35" width="35" title="great-work-told-is" src="https://avatars.githubusercontent.com/u/113922084?v=4" /></a>
      <a href="https://github.com/guilt"><img height="35" width="35" title="Karthik Kumar Viswanathan" src="https://avatars.githubusercontent.com/u/195178?v=4" /></a>
      <a href="https://github.com/inarikami"><img height="35" width="35" title="inarikami" src="https://avatars.githubusercontent.com/u/22864465?v=4" /></a>
      <a href="https://github.com/indeedeng"><img height="35" width="35" title="indeedeng" src="https://avatars.githubusercontent.com/u/2905043?s=200&v=4" /></a>
      <a href="https://github.com/JeremyGrosser"><img height="35" width="35" title="JeremyGrosser" src="https://avatars.githubusercontent.com/u/2151?v=4" /></a>
      <a href="https://github.com/maxesisn"><img height="35" width="35" title="Maximilian Wu" src="https://avatars.githubusercontent.com/u/20412597?v=4" /></a>
      <a href="https://github.com/Mehver"><img height="35" width="35" title="Mehver" src="https://avatars.githubusercontent.com/u/75297777?v=4" /></a>
      <a href="https://github.com/mirbyte"><img height="35" width="35" title="mirko" src="https://avatars.githubusercontent.com/u/83219244?v=4" /></a>
      <a href="https://github.com/PySimpleGUI"><img height="35" width="35" title="PySimpleGUI" src="https://avatars.githubusercontent.com/u/46163555?v=4" /></a>
      <a href="https://github.com/robusta-dev"><img height="35" width="35" title="Robusta" src="https://avatars.githubusercontent.com/u/82757710?s=200&v=4" /></a>
      <a href="https://github.com/sasozivanovic"><img height="35" width="35" title="Sašo Živanović" src="https://avatars.githubusercontent.com/u/3317028?v=4" /></a>
      <a href="https://github.com/scoutapm-sponsorships"><img height="35" width="35" title="scoutapm-sponsorships" src="https://avatars.githubusercontent.com/u/71095532?v=4" /></a>
      <a href="https://github.com/u93"><img height="35" width="35" title="Eugenio E Breijo" src="https://avatars.githubusercontent.com/u/16807302?v=4" /></a>
      <a href="https://opencollective.com/alexey-vazhnov"><img height="35" width="35" title="Alexey Vazhnov" src="https://images.opencollective.com/alexey-vazhnov/daed334/avatar/40.png" /></a>
      <a href="https://opencollective.com/chenyoo-hao"><img height="35" width="35" title="Chenyoo Hao" src="https://images.opencollective.com/chenyoo-hao/avatar/40.png" /></a>
    </div>

    <sup><a href="https://github.com/sponsors/giampaolo">add your avatar</a></sup>

.. </PYPI-EXCLUDE>

----

Example usages
==============

Below are interactive examples demonstrating all parts of the psutil API,
including CPU, memory, disks, network, sensors, and process management.

CPU
---

.. code-block:: python

    >>> import psutil
    >>>
    >>> psutil.cpu_times()
    scputimes(user=3961.46, nice=169.729, system=2150.659, idle=16900.540, iowait=629.59, irq=0.0, softirq=19.42, steal=0.0, guest=0, guest_nice=0.0)
    >>>
    >>> for x in range(3):
    ...     psutil.cpu_percent(interval=1)
    ...
    4.0
    5.9
    3.8
    >>>
    >>> for x in range(3):
    ...     psutil.cpu_percent(interval=1, percpu=True)
    ...
    [4.0, 6.9, 3.7, 9.2]
    [7.0, 8.5, 2.4, 2.1]
    [1.2, 9.0, 9.9, 7.2]
    >>>
    >>> for x in range(3):
    ...     psutil.cpu_times_percent(interval=1, percpu=False)
    ...
    scputimes(user=1.5, nice=0.0, system=0.5, idle=96.5, iowait=1.5, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
    scputimes(user=1.0, nice=0.0, system=0.0, idle=99.0, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
    scputimes(user=2.0, nice=0.0, system=0.0, idle=98.0, iowait=0.0, irq=0.0, softirq=0.0, steal=0.0, guest=0.0, guest_nice=0.0)
    >>>
    >>> psutil.cpu_count()
    4
    >>> psutil.cpu_count(logical=False)
    2
    >>>
    >>> psutil.cpu_stats()
    scpustats(ctx_switches=20455687, interrupts=6598984, soft_interrupts=2134212, syscalls=0)
    >>>
    >>> psutil.cpu_freq()
    scpufreq(current=931.42925, min=800.0, max=3500.0)
    >>>
    >>> psutil.getloadavg()  # also on Windows (emulated)
    (3.14, 3.89, 4.67)

Memory
------

.. code-block:: python

    >>> psutil.virtual_memory()
    svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304)
    >>> psutil.swap_memory()
    sswap(total=2097147904, used=296128512, free=1801019392, percent=14.1, sin=304193536, sout=677842944)
    >>>

Disks
-----

.. code-block:: python

    >>> psutil.disk_partitions()
    [sdiskpart(device='/dev/sda1', mountpoint='/', fstype='ext4', opts='rw,nosuid'),
     sdiskpart(device='/dev/sda2', mountpoint='/home', fstype='ext', opts='rw')]
    >>>
    >>> psutil.disk_usage('/')
    sdiskusage(total=21378641920, used=4809781248, free=15482871808, percent=22.5)
    >>>
    >>> psutil.disk_io_counters(perdisk=False)
    sdiskio(read_count=719566, write_count=1082197, read_bytes=18626220032, write_bytes=24081764352, read_time=5023392, write_time=63199568, read_merged_count=619166, write_merged_count=812396, busy_time=4523412)
    >>>

Network
-------

.. code-block:: python

    >>> psutil.net_io_counters(pernic=True)
    {'eth0': netio(bytes_sent=485291293, bytes_recv=6004858642, packets_sent=3251564, packets_recv=4787798, errin=0, errout=0, dropin=0, dropout=0),
     'lo': netio(bytes_sent=2838627, bytes_recv=2838627, packets_sent=30567, packets_recv=30567, errin=0, errout=0, dropin=0, dropout=0)}
    >>>
    >>> psutil.net_connections(kind='tcp')
    [sconn(fd=115, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status='ESTABLISHED', pid=1254),
     sconn(fd=117, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=43761), raddr=addr(ip='72.14.234.100', port=80), status='CLOSING', pid=2987),
     ...]
    >>>
    >>> psutil.net_if_addrs()
    {'lo': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='127.0.0.1', netmask='255.0.0.0', broadcast='127.0.0.1', ptp=None),
            snicaddr(family=<AddressFamily.AF_INET6: 10>, address='::1', netmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', broadcast=None, ptp=None),
            snicaddr(family=<AddressFamily.AF_LINK: 17>, address='00:00:00:00:00:00', netmask=None, broadcast='00:00:00:00:00:00', ptp=None)],
     'wlan0': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='192.168.1.3', netmask='255.255.255.0', broadcast='192.168.1.255', ptp=None),
               snicaddr(family=<AddressFamily.AF_INET6: 10>, address='fe80::c685:8ff:fe45:641%wlan0', netmask='ffff:ffff:ffff:ffff::', broadcast=None, ptp=None),
               snicaddr(family=<AddressFamily.AF_LINK: 17>, address='c4:85:08:45:06:41', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)]}
    >>>
    >>> psutil.net_if_stats()
    {'lo': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=0, mtu=65536, flags='up,loopback,running'),
     'wlan0': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=100, mtu=1500, flags='up,broadcast,running,multicast')}
    >>>

Sensors
-------

.. code-block:: python

    >>> import psutil
    >>> psutil.sensors_temperatures()
    {'acpitz': [shwtemp(label='', current=47.0, high=103.0, critical=103.0)],
     'asus': [shwtemp(label='', current=47.0, high=None, critical=None)],
     'coretemp': [shwtemp(label='Physical id 0', current=52.0, high=100.0, critical=100.0),
                  shwtemp(label='Core 0', current=45.0, high=100.0, critical=100.0)]}
    >>>
    >>> psutil.sensors_fans()
    {'asus': [sfan(label='cpu_fan', current=3200)]}
    >>>
    >>> psutil.sensors_battery()
    sbattery(percent=93, secsleft=16628, power_plugged=False)
    >>>

Other system info
-----------------

.. code-block:: python

    >>> import psutil
    >>> psutil.users()
    [suser(name='giampaolo', terminal='pts/2', host='localhost', started=1340737536.0, pid=1352),
     suser(name='giampaolo', terminal='pts/3', host='localhost', started=1340737792.0, pid=1788)]
    >>>
    >>> psutil.boot_time()
    1365519115.0
    >>>

Process management
------------------

.. code-block:: python

    >>> import psutil
    >>> psutil.pids()
    [1, 2, 3, 4, 5, 6, 7, 46, 48, 50, 51, 178, 182, 222, 223, 224, 268, 1215,
     1216, 1220, 1221, 1243, 1244, 1301, 1601, 2237, 2355, 2637, 2774, 3932,
     4176, 4177, 4185, 4187, 4189, 4225, 4243, 4245, 4263, 4282, 4306, 4311,
     4312, 4313, 4314, 4337, 4339, 4357, 4358, 4363, 4383, 4395, 4408, 4433,
     4443, 4445, 4446, 5167, 5234, 5235, 5252, 5318, 5424, 5644, 6987, 7054,
     7055, 7071]
    >>>
    >>> p = psutil.Process(7055)
    >>> p
    psutil.Process(pid=7055, name='python3', status=<ProcessStatus.STATUS_RUNNING: 'running'>, started='09:04:44')
    >>> p.pid
    7055
    >>> p.name()
    'python3'
    >>> p.exe()
    '/usr/bin/python3'
    >>> p.cwd()
    '/home/giampaolo'
    >>> p.cmdline()
    ['/usr/bin/python3', 'main.py']
    >>>
    >>> p.ppid()
    7054
    >>> p.parent()
    psutil.Process(pid=4699, name='bash', status=<ProcessStatus.STATUS_SLEEPING: 'sleeping'>, started='09:06:44')
    >>> p.parents()
    [psutil.Process(pid=4699, name='bash', started='09:06:44'),
     psutil.Process(pid=4689, name='gnome-terminal-server', status=<ProcessStatus.STATUS_SLEEPING: 'sleeping'>, started='0:06:44'),
     psutil.Process(pid=1, name='systemd', status=<ProcessStatus.STATUS_SLEEPING: 'sleeping'>, started='05:56:55')]
    >>> p.children(recursive=True)
    [psutil.Process(pid=29835, name='python3', status=<ProcessStatus.STATUS_SLEEPING: 'sleeping'>, started='11:45:38'),
     psutil.Process(pid=29836, name='python3', status=<ProcessStatus.STATUS_WAKING: 'waking'>, started='11:43:39')]
    >>>
    >>> p.status()
    <ProcessStatus.STATUS_RUNNING: 'running'>
    >>> p.create_time()
    1267551141.5019531
    >>> p.terminal()
    '/dev/pts/0'
    >>>
    >>> p.username()
    'giampaolo'
    >>> p.uids()
    puids(real=1000, effective=1000, saved=1000)
    >>> p.gids()
    pgids(real=1000, effective=1000, saved=1000)
    >>>
    >>> p.cpu_times()
    pcputimes(user=1.02, system=0.31, children_user=0.32, children_system=0.1, iowait=0.0)
    >>> p.cpu_percent(interval=1.0)
    12.1
    >>> p.cpu_affinity()
    [0, 1, 2, 3]
    >>> p.cpu_affinity([0, 1])  # set
    >>> p.cpu_num()
    1
    >>>
    >>> p.memory_info()
    pmem(rss=3164160, vms=4410163, shared=897433, text=302694, data=2422374)
    >>> p.memory_info_ex()
    pmem_ex(rss=3164160, vms=4410163, shared=897433, text=302694, data=2422374, peak_rss=4172190, peak_vms=6399001, rss_anon=2266726, rss_file=897433, rss_shmem=0, swap=0, hugetlb=0)
    >>> p.memory_footprint()  # "real" USS memory usage
    pfootprint(uss=2355200, pss=2483712, swap=0)
    >>> p.memory_percent()
    0.7823
    >>> p.memory_maps()
    [pmmap_grouped(path='/lib/x8664-linux-gnu/libutil-2.15.so', rss=32768, size=2125824, pss=32768, shared_clean=0, shared_dirty=0, private_clean=20480, private_dirty=12288, referenced=32768, anonymous=12288, swap=0),
     pmmap_grouped(path='/lib/x8664-linux-gnu/libc-2.15.so', rss=3821568, size=3842048, pss=3821568, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=3821568, referenced=3575808, anonymous=3821568, swap=0),
     pmmap_grouped(path='[heap]',  rss=32768, size=139264, pss=32768, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=32768, referenced=32768, anonymous=32768, swap=0),
     pmmap_grouped(path='[stack]', rss=2465792, size=2494464, pss=2465792, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=2465792, referenced=2277376, anonymous=2465792, swap=0),
     ...]
    >>>
    >>> p.page_faults()
    ppagefaults(minor=5905, major=3)
    >>>
    >>> p.io_counters()
    pio(read_count=478001, write_count=59371, read_bytes=700416, write_bytes=69632, read_chars=456232, write_chars=517543)
    >>>
    >>> p.open_files()
    [popenfile(path='/home/giampaolo/monit.py', fd=3, position=0, mode='r', flags=32768),
     popenfile(path='/var/log/monit.log', fd=4, position=235542, mode='a', flags=33793)]
    >>>
    >>> p.net_connections(kind='tcp')
    [pconn(fd=115, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status=<ConnectionStatus.CONN_ESTABLISHED: 'ESTABLISHED'>),
     pconn(fd=117, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=43761), raddr=addr(ip='72.14.234.100', port=80), status=<ConnectionStatus.CONN_CLOSING: 'CLOSING'>)]
    >>>
    >>> p.threads()
    [pthread(id=5234, user_time=22.5, system_time=9.2891),
     pthread(id=5237, user_time=0.0707, system_time=1.1)]
    >>>
    >>> p.num_threads()
    4
    >>> p.num_fds()
    8
    >>> p.num_ctx_switches()
    pctxsw(voluntary=78, involuntary=19)
    >>>
    >>> p.nice()
    0
    >>> p.nice(10)  # set
    >>>
    >>> p.ionice(psutil.IOPRIO_CLASS_IDLE)  # IO priority (Win and Linux only)
    >>> p.ionice()
    pionice(ioclass=<ProcessIOPriority.IOPRIO_CLASS_IDLE: 3>, value=0)
    >>>
    >>> p.rlimit(psutil.RLIMIT_NOFILE, (5, 5))  # set resource limits (Linux only)
    >>> p.rlimit(psutil.RLIMIT_NOFILE)
    (5, 5)
    >>>
    >>> p.environ()
    {'LC_PAPER': 'it_IT.UTF-8', 'SHELL': '/bin/bash', 'GREP_OPTIONS': '--color=auto',
    'XDG_CONFIG_DIRS': '/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg',
     ...}
    >>>
    >>> p.as_dict()
    {'status': <ProcessStatus.STATUS_RUNNING: 'running'>, 'num_ctx_switches': pctxsw(voluntary=63, involuntary=1), 'pid': 5457, ...}
    >>> p.is_running()
    True
    >>> p.suspend()
    >>> p.resume()
    >>>
    >>> p.terminate()
    >>> p.kill()
    >>> p.wait(timeout=3)
    <Exitcode.EX_OK: 0>
    >>>
    >>> psutil.test()
    USER         PID %CPU %MEM     VSZ     RSS TTY        START    TIME  COMMAND
    root           1  0.0  0.0   24584    2240            Jun17   00:00  init
    root           2  0.0  0.0       0       0            Jun17   00:00  kthreadd
    ...
    giampaolo  31475  0.0  0.0   20760    3024 /dev/pts/0 Jun19   00:00  python2.4
    giampaolo  31721  0.0  2.2  773060  181896            00:04   10:30  chrome
    root       31763  0.0  0.0       0       0            00:05   00:00  kworker/0:1
    >>>

Further process APIs
--------------------

.. code-block:: python

    >>> import psutil
    >>> for proc in psutil.process_iter(['pid', 'name']):
    ...     print(proc.info)
    ...
    {'pid': 1, 'name': 'systemd'}
    {'pid': 2, 'name': 'kthreadd'}
    {'pid': 3, 'name': 'ksoftirqd/0'}
    ...
    >>>
    >>> psutil.pid_exists(3)
    True
    >>>
    >>> def on_terminate(proc):
    ...     print("process {} terminated".format(proc))
    ...
    >>> # waits for multiple processes to terminate
    >>> gone, alive = psutil.wait_procs(procs_list, timeout=3, callback=on_terminate)
    >>>

Heap info
---------

.. code-block:: python

    >>> import psutil
    >>> psutil.heap_info()
    pheap(heap_used=5177792, mmap_used=819200)
    >>> psutil.heap_trim()

See also `psleak`_.

Windows services
----------------

.. code-block:: python

    >>> list(psutil.win_service_iter())
    [<WindowsService(name='AeLookupSvc', display_name='Application Experience') at 38850096>,
     <WindowsService(name='ALG', display_name='Application Layer Gateway Service') at 38850128>,
     <WindowsService(name='APNMCP', display_name='Ask Update Service') at 38850160>,
     <WindowsService(name='AppIDSvc', display_name='Application Identity') at 38850192>,
     ...]
    >>> s = psutil.win_service_get('alg')
    >>> s.as_dict()
    {'binpath': 'C:\\Windows\\System32\\alg.exe',
     'description': 'Provides support for 3rd party protocol plug-ins for Internet Connection Sharing',
     'display_name': 'Application Layer Gateway Service',
     'name': 'alg',
     'pid': None,
     'start_type': 'manual',
     'status': 'stopped',
     'username': 'NT AUTHORITY\\LocalService'}


.. _`psleak`: https://github.com/giampaolo/psleak
.. _`shell equivalents`: https://psutil.readthedocs.io/en/latest/shell_equivalents.html
.. _`top 100`: https://clickpy.clickhouse.com/dashboard/psutil


================================================
FILE: SECURITY.md
================================================
# Security Policy

If you have discovered a security vulnerability in this project, please report
it privately. **Do not disclose it as a public issue**. This gives me time to
fix the issue before public exposure, reducing the chance that an exploit will
be used before a patch is released.

To report a security vulnerability use the
[Tidelift security contact](https://tidelift.com/security). Tidelift will
coordinate the fix and the disclosure of the reported problem.


================================================
FILE: _bootstrap.py
================================================
# Copyright (c) 2009 Giampaolo Rodola. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Bootstrap utilities for loading psutil modules without psutil
being installed.
"""

import ast
import importlib.util
import os
import pathlib

ROOT_DIR = pathlib.Path(__file__).resolve().parent


def load_module(path):
    """Load a Python module by file path without importing it
    as part of a package.
    """
    name = os.path.splitext(os.path.basename(path))[0]
    spec = importlib.util.spec_from_file_location(name, path)
    mod = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(mod)
    return mod


def get_version():
    """Extract __version__ from psutil/__init__.py using AST
    (no imports needed).
    """
    path = ROOT_DIR / "psutil" / "__init__.py"
    with open(path, encoding="utf-8") as f:
        mod = ast.parse(f.read())
    for node in mod.body:
        if isinstance(node, ast.Assign):
            for target in node.targets:
                if getattr(target, "id", None) == "__version__":
                    return ast.literal_eval(node.value)
    msg = "could not find __version__"
    raise RuntimeError(msg)


================================================
FILE: docs/.readthedocs.yaml
================================================
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 2

build:
  os: ubuntu-22.04
  tools:
    python: "3.11"

# Build documentation in the docs/ directory with Sphinx
sphinx:
  configuration: docs/conf.py

# RTD recommends specifying your dependencies to enable reproducible builds:
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
  install:
    - requirements: docs/requirements.txt


================================================
FILE: docs/DEVNOTES
================================================
TODO
====

A collection of ideas and notes about stuff to implement in future versions.
"#NNN" occurrences refer to bug tracker issues at:
https://github.com/giampaolo/psutil/issues

FEATURES
========

- (UNIX) process root (different from cwd)

- (Linux) locked files via /proc/locks:
  https://www.centos.org/docs/5/html/5.2/Deployment_Guide/s2-proc-locks.html

- #269: NIC rx/tx queue. This should probably go into net_if_stats().
  Figure out on what platforms this is supported:
  Linux: yes
  Others: ?

- Asynchronous psutil.Popen (see http://bugs.python.org/issue1191964)

- (Windows) fall back on using WMIC for Process methods returning AccessDenied

- #613: thread names; patch for macOS available at:
  https://code.google.com/p/plcrashreporter/issues/detail?id=65
  Sample code:
  https://github.com/janmojzis/pstree/blob/master/proc_kvm.c

- scripts/taskmgr-gui.py (using tk).

- system-wide number of open file descriptors:
  - https://jira.hyperic.com/browse/SIGAR-30

- Number of system threads.
  - Windows: http://msdn.microsoft.com/en-us/library/windows/desktop/ms684824(v=vs.85).aspx

- Doc / wiki which compares similarities between UNIX cli tools and psutil.
  Example:
  ```
  df -a  ->  psutil.disk_partitions
  lsof  ->  psutil.Process.open_files() and psutil.Process.net_connections()
  killall->  (actual script)
  tty  ->  psutil.Process.terminal()
  who  ->  psutil.users()
  ```

- psutil.proc_tree() something which obtains a {pid:ppid, ...} dict for
  all running processes in one shot. This can be factored out from
  Process.children() and exposed as a first class function.
  PROS: on Windows we can take advantage of _psutil_windows.ppid_map()
  which is faster than iterating over all pids and calling ppid().
  CONS: scripts/pstree.py shows this can be easily done in the user code
  so maybe it's not worth the addition.

- advanced cmdline interface exposing the whole API and providing different
  kind of outputs (e.g. pprinted, colorized, json).

- [Linux]: process cgroups (http://en.wikipedia.org/wiki/Cgroups). They look
  similar to prlimit() in terms of functionality but uglier (they should allow
  limiting per-process network IO resources though, which is great). Needs
  further reading.

- Python 3.3. exposed different sched.h functions:
  http://docs.python.org/dev/whatsnew/3.3.html#os
  http://bugs.python.org/issue12655
  http://docs.python.org/dev/library/os.html#interface-to-the-scheduler
  It might be worth to take a look and figure out whether we can include some
  of those in psutil.
  Also, we can probably reimplement wait_pid() on POSIX which is currently
  implemented as a busy-loop.

- os.times() provides 'elapsed' times (cpu_times() might).

- ...also guest_time and cguest_time on Linux.

- Enrich exception classes hierarchy on Python >= 3.3 / post PEP-3151 so that:
   - NoSuchProcess inherits from ProcessLookupError
   - AccessDenied inherits from PermissionError
   - TimeoutExpired inherits from TimeoutError (debatable)
   See: http://docs.python.org/3/library/exceptions.html#os-exceptions

- Process.threads() might grow an extra "id" parameter so that it can be
   used as such:
  ```
  >>> p = psutil.Process(os.getpid())
  >>> p.threads(id=psutil.current_thread_id())
  thread(id=2539, user_time=0.03, system_time=0.02)
  >>>
  ```
  Note: this leads to questions such as "should we have a custom NoSuchThread
  exception? Also see issue #418.
  Note #2: this would work with os.getpid() only.
  psutil.current_thread_id() might be desirable as per issue #418 though.

- should psutil.TimeoutExpired exception have a 'msg' kwarg similar to
  NoSuchProcess and AccessDenied? Not that we need it, but currently we
  cannot raise a TimeoutExpired exception with a specific error string.

- round Process.memory_percent() result?

BUGFIXES
========

- #600: windows / open_files(): support network file handles.

REJECTED IDEAS
==============

- #550: threads per core
- #1667: process_iter(new_only=True)

INCONSISTENCIES
===============

- PROCFS_PATH should have been set_procfs_path().
- `virtual_memory()` should have been `memory_virtual()`.
- `swap_memory()` should have been `memory_swap()`.

RESOURCES
=========

- conky: https://github.com/brndnmtthws/conky/
- sigar: https://github.com/hyperic/sigar (Java)
- zabbix: https://zabbix.org/wiki/Get_Zabbix
- libstatgrab: http://www.i-scream.org/libstatgrab/
- top: http://www.unixtop.org/
- oshi: https://github.com/oshi/oshi
- netdata: https://github.com/netdata/netdata

STATS
=====

- https://pepy.tech/projects/psutil
- https://clickpy.clickhouse.com/dashboard/psutil
- https://pypistats.org/packages/psutil


================================================
FILE: docs/Makefile
================================================
# Makefile for Sphinx documentation

PYTHON = python3
SPHINXBUILD = $(PYTHON) -m sphinx
BUILDDIR = _build
ALLSPHINXOPTS = --fail-on-warning -d $(BUILDDIR)/doctrees .

clean:  ## Remove all build files
	rm -rf $(BUILDDIR)

html:  ## Generate doc in HTML format
	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

singlehtml:  ## Generate doc as a single HTML page
	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

text:  ## Generate doc in .txt format
	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
	@echo "Build finished. The text files are in $(BUILDDIR)/text."

auto-build:  ## Rebuild HTML on file changes (requires inotify-tools)
	$(MAKE) clean
	$(MAKE) html
	while inotifywait -r -e modify,create,delete,move .; do $(MAKE) html; done

check-links:  ## Check links
	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
	@echo "Link check complete; look for any errors in the above output " \
	      "or in $(BUILDDIR)/linkcheck/output.txt."

help: ## Display callable targets.
	@awk -F':.*?## ' '/^[a-zA-Z0-9_.-]+:.*?## / {printf "\033[36m%-24s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort


================================================
FILE: docs/README
================================================
About
=====

This directory contains the reStructuredText (reST) sources to the psutil
documentation.  You don't need to build them yourself, prebuilt versions are
available at http://psutil.readthedocs.io.
In case you want, you need to install sphinx first:

    $ pip install sphinx

Then run:

    $ make html

You'll then have an HTML version of the doc at _build/html/index.html.


================================================
FILE: docs/_ext/add_home_link.py
================================================
# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Sphinx extension that prepends a 'Home' link to the TOC sidebar.
This script gets called on `make html`.
"""

from sphinx.application import Sphinx


def add_home_link(app: Sphinx, pagename, templatename, context, doctree):
    if "toctree" in context:
        toctree_func = context["toctree"]
        toc_html = toctree_func(
            maxdepth=2, collapse=False, includehidden=False
        )
        # prepend Home link manually
        home_link = '<li class="toctree-l1"><a href="index.html">Home</a></li>'
        context["toctree"] = lambda **_kw: home_link + toc_html


def setup(app: Sphinx):
    app.connect("html-page-context", add_home_link)


================================================
FILE: docs/_ext/availability.py
================================================
# noqa: CPY001

# Slightly adapted from CPython's:
# https://github.com/python/cpython/blob/main/Doc/tools/extensions/availability.py
# Copyright (c) PSF
# Licensed under the Python Software Foundation License Version 2.

"""Support for `.. availability:: …` directive, to document platform
availability.
"""

from docutils import nodes
from sphinx.locale import _ as sphinx_gettext
from sphinx.util import logging
from sphinx.util.docutils import SphinxDirective

logger = logging.getLogger(__name__)

_PLATFORMS = frozenset({
    "AIX",
    "BSD",
    "FreeBSD",
    "Linux",
    "Linux with glibc",
    "macOS",
    "NetBSD",
    "OpenBSD",
    "POSIX",
    "SunOS",
    "UNIX",
    "Windows",
})

_LIBC = frozenset({
    "glibc",
    "musl",
})

KNOWN_PLATFORMS = _PLATFORMS | _LIBC


class Availability(SphinxDirective):
    has_content = True
    required_arguments = 1
    optional_arguments = 0
    final_argument_whitespace = True

    def run(self):
        title = sphinx_gettext("Availability")
        sep = nodes.Text(": ")
        parsed, msgs = self.state.inline_text(self.arguments[0], self.lineno)
        pnode = nodes.paragraph(
            title, "", nodes.emphasis(title, title), sep, *parsed, *msgs
        )
        self.set_source_info(pnode)
        cnode = nodes.container("", pnode, classes=["availability"])
        self.set_source_info(cnode)
        if self.content:
            self.state.nested_parse(self.content, self.content_offset, cnode)
        self.parse_platforms()

        return [cnode]

    def parse_platforms(self):
        """Parse platform information from arguments

        Arguments is a comma-separated string of platforms. A platform may
        be prefixed with "not " to indicate that a feature is not available.
        Example::

           .. availability:: Windows, Linux >= 4.2, not glibc
        """
        platforms = {}
        for arg in self.arguments[0].rstrip(".").split(","):
            arg = arg.strip()
            platform, _, version = arg.partition(" >= ")
            if platform.startswith("not "):
                version = False
                platform = platform.removeprefix("not ")
            elif not version:
                version = True
            platforms[platform] = version

        unknown = set(platforms).difference(KNOWN_PLATFORMS)
        if unknown:
            logger.warning(
                "Unknown platform%s or syntax '%s' in '.. availability:: %s', "
                "see %s:KNOWN_PLATFORMS for a set of known platforms.",
                "s" if len(platforms) != 1 else "",
                " ".join(sorted(unknown)),
                self.arguments[0],
                __file__,
                location=self.get_location(),
            )

        return platforms


def setup(app):
    app.add_directive("availability", Availability)
    return {
        "version": "1.0",
        "parallel_read_safe": True,
        "parallel_write_safe": True,
    }


================================================
FILE: docs/_ext/changelog_anchors.py
================================================
# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Sphinx extension for adding anchors to each section in
docs/changelog.rst.

This script gets called on `make html`, and adds numeric anchors for
version titles (e.g., 7.2.3 -> #723).
"""

import re

from docutils import nodes

VERSION_RE = re.compile(r"^(\d+\.\d+\.\d+)")


def add_version_anchors(app, doctree, docname):
    if docname != "changelog":
        return

    for node in doctree.traverse(nodes.section):
        title = node.next_node(nodes.title)
        if not title:
            continue

        text = title.astext()
        m = VERSION_RE.match(text)
        if m:
            anchor = m.group(1).replace(".", "")
            if anchor not in node["ids"]:
                node["ids"].insert(0, anchor)


def setup(app):
    app.connect("doctree-resolved", add_version_anchors)


================================================
FILE: docs/_ext/check_python_syntax.py
================================================
# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""Sphinx extension that checks the Python syntax of code blocks in the
documentation. This script gets called on `make html`.
"""

import ast

import docutils.nodes
import sphinx.errors


def check_python_blocks(app, doctree, docname):
    path = app.env.doc2path(docname)

    for node in doctree.traverse(docutils.nodes.literal_block):
        lang = node.get("language")
        if lang not in {"python", "py"}:
            continue

        code = node.astext()

        # skip empty blocks
        if not code.strip():
            continue

        # skip REPL examples containing >>>
        if ">>>" in code:
            continue

        try:
            ast.parse(code)
        except SyntaxError as err:
            lineno = node.line or "?"
            msg = (
                f"invalid Python syntax in {path}:{lineno}:\n\n{code}\n\n{err}"
            )
            raise sphinx.errors.SphinxError(msg) from None


def setup(app):
    app.connect("doctree-resolved", check_python_blocks)


================================================
FILE: docs/_links.rst
================================================


================================================
FILE: docs/_static/copybutton.js
================================================
$(document).ready(function() {
    /* Add a [>>>] button on the top-right corner of code samples to hide
     * the >>> and ... prompts and the output and thus make the code
     * copyable. */
    var div = $('.highlight-python .highlight,' +
                '.highlight-python3 .highlight')
    var pre = div.find('pre');

    // get the styles from the current theme
    pre.parent().parent().css('position', 'relative');
    var hide_text = 'Hide the prompts and output';
    var show_text = 'Show the prompts and output';
    var border_width = pre.css('border-top-width');
    var border_style = pre.css('border-top-style');
    var border_color = pre.css('border-top-color');
    var button_styles = {
        'cursor':'pointer', 'position': 'absolute', 'top': '0', 'right': '0',
        'border-color': border_color, 'border-style': border_style,
        'border-width': border_width, 'color': border_color, 'text-size': '75%',
        'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em',
        'border-radius': '0 3px 0 0'
    }

    // create and add the button to all the code blocks that contain >>>
    div.each(function(index) {
        var jthis = $(this);
        if (jthis.find('.gp').length > 0) {
            var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
            button.css(button_styles)
            button.attr('title', hide_text);
            jthis.prepend(button);
        }
        // tracebacks (.gt) contain bare text elements that need to be
        // wrapped in a span to work with .nextUntil() (see later)
        jthis.find('pre:has(.gt)').contents().filter(function() {
            return ((this.nodeType == 3) && (this.data.trim().length > 0));
        }).wrap('<span>');
    });

    // define the behavior of the button when it's clicked
    $('.copybutton').toggle(
        function() {
            var button = $(this);
            button.parent().find('.go, .gp, .gt').hide();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
            button.css('text-decoration', 'line-through');
            button.attr('title', show_text);
        },
        function() {
            var button = $(this);
            button.parent().find('.go, .gp, .gt').show();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
            button.css('text-decoration', 'none');
            button.attr('title', hide_text);
        });
});



================================================
FILE: docs/_static/css/custom.css
================================================
/* ================================================================== */
/* Layout                                                             */
/* ================================================================== */

@media (min-width: 1200px) {
    .wy-nav-content {
        max-width: 1000px;
        padding-left: 20px !important;
    }
}

/* ================================================================== */
/* Navigation                                                         */
/* ================================================================== */

/* hide top navigation, keep footer navigation */
.rst-content > div[role="navigation"] {
    display: none;
}

footer div[role="navigation"][aria-label="Footer"] {
    display: block;
}

/* ================================================================== */
/* Sidebar                                                            */
/* ================================================================== */

.wy-side-nav-search {
    background-color: grey !important
}

/* ================================================================== */
/* Headings                                                           */
/* ================================================================== */

h1, h2, h3 {
    background: #eee;
    padding: 5px;
    border-bottom: 1px solid #ccc;
}

h1 {
    font-size: 35px;
}

/* ================================================================== */
/* Tables                                                             */
/* ================================================================== */

.wy-table-responsive table thead {
    background-color: #eeeeee;
}

.document th {
    padding: 4px 8px !important;
    font-weight: 600;
}

.document th p {
    margin-bottom: 0px !important;
}

.document td {
    padding: 4px 8px !important;
}

.document td p {
    margin-bottom: 0px !important;
}

/* "longtable" class (used by alternatives.rst): fixed layout
   with extra padding for multi-line cells */
.wy-table-responsive table.longtable {
    table-layout: fixed;
    width: 100%;
}

.wy-table-responsive table.longtable th,
.wy-table-responsive table.longtable td {
    padding: 10px !important;
    white-space: normal !important;
    word-wrap: break-word;
}

/* adoption page logos */
.document td img[alt$="-logo"] {
    height: 20px !important;
    width: 20px !important;
    vertical-align: middle;
}

/* ================================================================== */
/* Lists                                                              */
/* ================================================================== */

.rst-content ul {
    margin-top: 0px !important;
}

.rst-content ul p {
    margin-bottom: 0px !important;
}

.rst-content li {
    list-style: outside;
    margin-left: 15px;
}

/* ================================================================== */
/* API signatures                                                     */
/* ================================================================== */

.rst-content dl:not(.docutils) {
    margin: 0px 0px 0px 0px !important;
}

.rst-content dl:not(.docutils) dt {
    color: #555;
}

.data dd {
    margin-bottom: 0px !important;
}

.data .descname {
    border-right:10px !important;
}

.function .descclassname,
.class .descclassname {
    font-weight: normal !important;
}

.sig-paren {
    padding-left: 2px;
    padding-right: 2px;
}

/* ================================================================== */
/* Code blocks                                                        */
/* ================================================================== */

pre {
    padding: 5px !important;
}

.highlight {
    background: #eeffcc;
}

.highlight .hll {
    background-color: #ffffcc
}

.highlight .c {
    color: #408090;
    font-style: italic
}

.codeblock div[class^='highlight'],
pre.literal-block div[class^='highlight'],
.rst-content .literal-block div[class^='highlight'],
div[class^='highlight'] div[class^='highlight'] {
    background-color: #eeffcc !important;
}

/* ================================================================== */
/* Links                                                              */
/* ================================================================== */

/* external links: dotted underline (except intersphinx) */
a.reference.external:not([href*="docs.python.org"]) {
    text-decoration: underline dotted;
}

a.reference.external:not([href*="docs.python.org"]):hover {
    text-decoration: underline solid;
}

a.external[href^="#"] {
    text-decoration: none;
    color: inherit;
}

/* ================================================================== */
/* Admonitions (note, warning, tip) - styled like python doc          */
/* ================================================================== */

div.admonition {
    margin-top: 10px !important;
    margin-bottom: 10px !important;
}

div.warning {
    background-color: #ffe4e4 !important;
    border: 1px solid #f66 !important;
    border-radius: 3px !important;
}

div.note {
    background-color: #eee !important;
    border: 1px solid #ccc !important;
    border-radius: 3px !important;
}

div.tip {
    background-color: #dfd !important;
    border: 1px solid green !important;
    border-radius: 3px !important;
}

div.admonition p.admonition-title + p {
    display: inline !important;
}

p.admonition-title {
    display: inline !important;
    background: none !important;
    color: black !important;
}

p.admonition-title:after {
    content: ":" !important;
}

/* hide admonition icons */
.fa-exclamation-circle:before,
.wy-inline-validate.wy-inline-validate-warning .wy-input-context:before,
.wy-inline-validate.wy-inline-validate-info .wy-input-context:before,
.rst-content .admonition-title:before {
    display: none !important;
}

.admonition.warning {
    padding-top: 5px !important;
    padding-bottom: 5px !important;
}

.admonition.warning p {
    margin-bottom: 5px !important;
}

.admonition.note {
    padding-top: 5px !important;
    padding-bottom: 5px !important;
}

.admonition.note p {
    margin-bottom: 5px !important;
}

.note code {
    background: #d6d6d6 !important;
}

/* ================================================================== */
/* Version directives (versionadded / versionchanged / deprecated)    */
/* ================================================================== */

div.versionadded,
div.versionchanged,
div.deprecated {
    border-left: 3px solid;
    padding: 0 1rem;
}

div.versionadded {
    border-left-color: rgb(79, 196, 100);
}

div.versionchanged {
    border-left-color: rgb(244, 227, 76);
}

div.deprecated {
    border-left-color: rgb(244, 76, 78);
}

div.versionadded .versionmodified {
    color: rgb(41, 100, 51);
}

div.versionchanged .versionmodified {
    color: rgb(133, 72, 38);
}

div.deprecated .versionmodified {
    color: rgb(159, 49, 51);
}


================================================
FILE: docs/_static/sidebar.js
================================================
/*
 * sidebar.js
 * ~~~~~~~~~~
 *
 * This script makes the Sphinx sidebar collapsible.
 *
 * .sphinxsidebar contains .sphinxsidebarwrapper.  This script adds in
 * .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton used to
 * collapse and expand the sidebar.
 *
 * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden and the
 * width of the sidebar and the margin-left of the document are decreased.
 * When the sidebar is expanded the opposite happens.  This script saves a
 * per-browser/per-session cookie used to remember the position of the sidebar
 * among the pages.  Once the browser is closed the cookie is deleted and the
 * position reset to the default (expanded).
 *
 * :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
 * :license: BSD, see LICENSE for details.
 *
 */

$(function() {
  // global elements used by the functions.
  // the 'sidebarbutton' element is defined as global after its
  // creation, in the add_sidebar_button function
  var bodywrapper = $('.bodywrapper');
  var sidebar = $('.sphinxsidebar');
  var sidebarwrapper = $('.sphinxsidebarwrapper');

  // original margin-left of the bodywrapper and width of the sidebar
  // with the sidebar expanded
  var bw_margin_expanded = bodywrapper.css('margin-left');
  var ssb_width_expanded = sidebar.width();

  // margin-left of the bodywrapper and width of the sidebar
  // with the sidebar collapsed
  var bw_margin_collapsed = '.8em';
  var ssb_width_collapsed = '.8em';

  // colors used by the current theme
  var dark_color = '#AAAAAA';
  var light_color = '#CCCCCC';

  function sidebar_is_collapsed() {
    return sidebarwrapper.is(':not(:visible)');
  }

  function toggle_sidebar() {
    if (sidebar_is_collapsed())
      expand_sidebar();
    else
      collapse_sidebar();
  }

  function collapse_sidebar() {
    sidebarwrapper.hide();
    sidebar.css('width', ssb_width_collapsed);
    bodywrapper.css('margin-left', bw_margin_collapsed);
    sidebarbutton.css({
        'margin-left': '0',
        //'height': bodywrapper.height(),
        'height': sidebar.height(),
        'border-radius': '5px'
    });
    sidebarbutton.find('span').text('»');
    sidebarbutton.attr('title', _('Expand sidebar'));
    document.cookie = 'sidebar=collapsed';
  }

  function expand_sidebar() {
    bodywrapper.css('margin-left', bw_margin_expanded);
    sidebar.css('width', ssb_width_expanded);
    sidebarwrapper.show();
    sidebarbutton.css({
        'margin-left': ssb_width_expanded-12,
        //'height': bodywrapper.height(),
        'height': sidebar.height(),
        'border-radius': '0 5px 5px 0'
    });
    sidebarbutton.find('span').text('«');
    sidebarbutton.attr('title', _('Collapse sidebar'));
    //sidebarwrapper.css({'padding-top':
    //  Math.max(window.pageYOffset - sidebarwrapper.offset().top, 10)});
    document.cookie = 'sidebar=expanded';
  }

  function add_sidebar_button() {
    sidebarwrapper.css({
        'float': 'left',
        'margin-right': '0',
        'width': ssb_width_expanded - 28
    });
    // create the button
    sidebar.append(
      '<div id="sidebarbutton"><span>&laquo;</span></div>'
    );
    var sidebarbutton = $('#sidebarbutton');
    // find the height of the viewport to center the '<<' in the page
    var viewport_height;
    if (window.innerHeight)
 	  viewport_height = window.innerHeight;
    else
	  viewport_height = $(window).height();
    var sidebar_offset = sidebar.offset().top;

    var sidebar_height = sidebar.height();
    //var sidebar_height = Math.max(bodywrapper.height(), sidebar.height());
    sidebarbutton.find('span').css({
        'display': 'block',
        'margin-top': sidebar_height/2 - 10
        //'margin-top': (viewport_height - sidebar.position().top - 20) / 2
        //'position': 'fixed',
        //'top': Math.min(viewport_height/2, sidebar_height/2 + sidebar_offset) - 10
    });

    sidebarbutton.click(toggle_sidebar);
    sidebarbutton.attr('title', _('Collapse sidebar'));
    sidebarbutton.css({
        'border-radius': '0 5px 5px 0',
        'color': '#444444',
        'background-color': '#CCCCCC',
        'font-size': '1.2em',
        'cursor': 'pointer',
        'height': sidebar_height,
        'padding-top': '1px',
        'padding-left': '1px',
        'margin-left': ssb_width_expanded - 12
    });

    sidebarbutton.hover(
      function () {
          $(this).css('background-color', dark_color);
      },
      function () {
          $(this).css('background-color', light_color);
      }
    );
  }

  function set_position_from_cookie() {
    if (!document.cookie)
      return;
    var items = document.cookie.split(';');
    for(var k=0; k<items.length; k++) {
      var key_val = items[k].split('=');
      var key = key_val[0];
      if (key == 'sidebar') {
        var value = key_val[1];
        if ((value == 'collapsed') && (!sidebar_is_collapsed()))
          collapse_sidebar();
        else if ((value == 'expanded') && (sidebar_is_collapsed()))
          expand_sidebar();
      }
    }
  }

  add_sidebar_button();
  var sidebarbutton = $('#sidebarbutton');
  set_position_from_cookie();
});


================================================
FILE: docs/_templates/layout.html
================================================
{% extends "!layout.html" %}
{% block extrahead %}
{{ super() }}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-G7374TFB11"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-G7374TFB11');
</script>
{% endblock %}


================================================
FILE: docs/adoption.rst
================================================
.. currentmodule:: psutil

Who uses psutil
===============

psutil is among the `top 100 <https://clickpy.clickhouse.com/dashboard/psutil>`__
most-downloaded packages on PyPI, with 280+ million downloads per month,
`760,000+ GitHub repositories <https://github.com/giampaolo/psutil/network/dependents>`__ using
it, and 14,000+ packages depending on it. The projects below are a small
sample of notable software that depends on it.

See also :doc:`alternatives` for related Python libraries and equivalents in
other languages.

Infrastructure / automation
---------------------------

.. list-table::
   :header-rows: 1
   :widths: 28 32 14 26

   * - Project
     - Description
     - Stars
     - psutil usage
   * - |homeassistant-logo| `Home Assistant <https://github.com/home-assistant/core>`__
     - Open source home automation platform
     - |homeassistant-stars|
     - system monitor integration
   * - |ansible-logo| `Ansible <https://github.com/ansible/ansible>`__
     - IT automation platform
     - |ansible-stars|
     - system fact gathering
   * - |airflow-logo| `Apache Airflow <https://github.com/apache/airflow>`__
     - Workflow orchestration platform
     - |airflow-stars|
     - process supervisor, unit testing
   * - |celery-logo| `Celery <https://github.com/celery/celery>`__
     - Distributed task queue
     - |celery-stars|
     - worker process monitoring, memleak detection
   * - |salt-logo| `Salt <https://github.com/saltstack/salt>`__
     - Infrastructure automation at scale
     - |salt-stars|
     - deep system data collection (grains)
   * - |dask-logo| `Dask <https://github.com/dask/dask>`__
     - Parallel computing with task scheduling
     - |dask-stars|
     - `metrics dashboard <https://github.com/dask/dask/blob/0d40a604284e021d098682b71c55d0387a414925/docs/source/dashboard.rst#L147>`__, profiling
   * - |ajenti-logo| `Ajenti <https://github.com/ajenti/ajenti>`__
     - Web-based server administration panel
     - |ajenti-stars|
     - monitoring plugins, deep integration

AI / machine learning
---------------------

.. list-table::
   :header-rows: 1
   :widths: 28 32 14 26

   * - Project
     - Description
     - Stars
     - psutil usage
   * - |tensorflow-logo| `TensorFlow <https://github.com/tensorflow/tensorflow>`__
     - Open source machine learning framework by Google
     - |tensorflow-stars|
     - unit tests
   * - |pytorch-logo| `PyTorch <https://github.com/pytorch/pytorch>`__
     - Tensors and dynamic neural networks with GPU acceleration
     - |pytorch-stars|
     - benchmark scripts
   * - |ray-logo| `Ray <https://github.com/ray-project/ray>`__
     - AI compute engine with distributed runtime
     - |ray-stars|
     - metrics dashboard
   * - |mlflow-logo| `MLflow <https://github.com/mlflow/mlflow>`__
     - AI/ML engineering platform
     - |mlflow-stars|
     - deep system monitoring integration

Developer tools
---------------

.. list-table::
   :header-rows: 1
   :widths: 28 32 14 26

   * - Project
     - Description
     - Stars
     - psutil usage
   * - |sentry-logo| `Sentry <https://github.com/getsentry/sentry>`__
     - Error tracking and performance monitoring
     - |sentry-stars|
     - send telemetry metrics
   * - |locust-logo| `Locust <https://github.com/locustio/locust>`__
     - Scalable load testing in Python
     - |locust-stars|
     - monitoring of the Locust process
   * - |spyder-logo| `Spyder <https://github.com/spyder-ide/spyder>`__
     - Scientific Python IDE
     - |spyder-stars|
     - deep integration, UI stats, process management
   * - |psleak-logo| `psleak <https://github.com/giampaolo/psleak>`__
     - Test framework to detect memory leaks in Python C extensions
     - |psleak-stars|
     - heap process memory (:func:`heap_info()`)

System monitoring
-----------------

.. list-table::
   :header-rows: 1
   :widths: 28 32 14 26

   * - Project
     - Description
     - Stars
     - psutil usage
   * - |glances-logo| `Glances <https://github.com/nicolargo/glances>`__
     - System monitoring tool (top/htop alternative)
     - |glances-stars|
     - core dependency for all metrics
   * - |bpytop-logo| `bpytop <https://github.com/aristocratos/bpytop>`__
     - Terminal resource monitor
     - |bpytop-stars|
     - core dependency for all metrics
   * - |auto-cpufreq-logo| `auto-cpufreq <https://github.com/AdnanHodzic/auto-cpufreq>`__
     - Automatic CPU speed and power optimizer for Linux
     - |auto-cpufreq-stars|
     - core dependency for CPU monitoring
   * - |grr-logo| `GRR <https://github.com/google/grr>`__
     - Remote live forensics by Google
     - |grr-stars|
     - endpoint system data collection, deep integration
   * - |stui-logo| `s-tui <https://github.com/amanusk/s-tui>`__
     - Terminal CPU stress and monitoring utility
     - |stui-stars|
     - core dependency for metrics
   * - |asitop-logo| `asitop <https://github.com/tlkh/asitop>`__
     - Apple Silicon performance monitoring CLI
     - |asitop-stars|
     - core dependency for system metrics
   * - |psdash-logo| `psdash <https://github.com/Jahaja/psdash>`__
     - Web dashboard using psutil and Flask
     - |psdash-stars|
     - core dependency for all metrics
   * - |dd-agent-logo| `dd-agent <https://github.com/DataDog/dd-agent>`__
     - Original monitoring agent by Datadog
     - |dd-agent-stars|
     - system metrics collection
   * - |ddtrace-logo| `dd-trace-py <https://github.com/DataDog/dd-trace-py>`__
     - Python tracing and profiling library
     - |ddtrace-stars|
     - system metrics collection

How this list was compiled
--------------------------

- `GitHub dependency graph <https://github.com/giampaolo/psutil/network/dependents>`__
  was used to identify packages and repositories that depend on psutil.
- GitHub code search with query "psutil in:readme language:Python", sorted
  by stars, was used to find additional projects that mention psutil in their
  README.
- Each candidate was then manually verified by checking the project's
  pyproject.toml, setup.py, setup.cfg or requirements.txt to confirm that
  psutil is an actual dependency (direct, build-time, or optional), not just
  a passing mention.
- Projects were excluded if they only mention psutil in documentation or
  examples without declaring it as a dependency.
- Star counts are pulled dynamically from `shields.io <https://shields.io/>`__ badges.
- The final list was manually curated to include notable projects and
  meaningful usages of psutil across different areas of the Python ecosystem.

.. ============================================================================
.. ============================================================================
.. ============================================================================

.. Star badges
.. ============================================================================

.. |airflow-stars| image:: https://img.shields.io/github/stars/apache/airflow.svg?style=social&label=%20
.. |ajenti-stars| image:: https://img.shields.io/github/stars/ajenti/ajenti.svg?style=social&label=%20
.. |ansible-stars| image:: https://img.shields.io/github/stars/ansible/ansible.svg?style=social&label=%20
.. |asitop-stars| image:: https://img.shields.io/github/stars/tlkh/asitop.svg?style=social&label=%20
.. |auto-cpufreq-stars| image:: https://img.shields.io/github/stars/AdnanHodzic/auto-cpufreq.svg?style=social&label=%20
.. |bpytop-stars| image:: https://img.shields.io/github/stars/aristocratos/bpytop.svg?style=social&label=%20
.. |celery-stars| image:: https://img.shields.io/github/stars/celery/celery.svg?style=social&label=%20
.. |dask-stars| image:: https://img.shields.io/github/stars/dask/dask.svg?style=social&label=%20
.. |ddtrace-stars| image:: https://img.shields.io/github/stars/DataDog/dd-trace-py.svg?style=social&label=%20
.. |dd-agent-stars| image:: https://img.shields.io/github/stars/DataDog/dd-agent.svg?style=social&label=%20
.. |glances-stars| image:: https://img.shields.io/github/stars/nicolargo/glances.svg?style=social&label=%20
.. |grr-stars| image:: https://img.shields.io/github/stars/google/grr.svg?style=social&label=%20
.. |homeassistant-stars| image:: https://img.shields.io/github/stars/home-assistant/core.svg?style=social&label=%20
.. |locust-stars| image:: https://img.shields.io/github/stars/locustio/locust.svg?style=social&label=%20
.. |mlflow-stars| image:: https://img.shields.io/github/stars/mlflow/mlflow.svg?style=social&label=%20
.. |psdash-stars| image:: https://img.shields.io/github/stars/Jahaja/psdash.svg?style=social&label=%20
.. |psleak-stars| image:: https://img.shields.io/github/stars/giampaolo/psleak.svg?style=social&label=%20
.. |pytorch-stars| image:: https://img.shields.io/github/stars/pytorch/pytorch.svg?style=social&label=%20
.. |ray-stars| image:: https://img.shields.io/github/stars/ray-project/ray.svg?style=social&label=%20
.. |salt-stars| image:: https://img.shields.io/github/stars/saltstack/salt.svg?style=social&label=%20
.. |sentry-stars| image:: https://img.shields.io/github/stars/getsentry/sentry.svg?style=social&label=%20
.. |spyder-stars| image:: https://img.shields.io/github/stars/spyder-ide/spyder.svg?style=social&label=%20
.. |stui-stars| image:: https://img.shields.io/github/stars/amanusk/s-tui.svg?style=social&label=%20
.. |tensorflow-stars| image:: https://img.shields.io/github/stars/tensorflow/tensorflow.svg?style=social&label=%20

.. Logo images
.. ============================================================================

.. |airflow-logo| image:: https://github.com/apache.png?s=28 :height: 28
.. |ajenti-logo| image:: https://github.com/ajenti.png?s=28 :height: 28
.. |ansible-logo| image:: https://github.com/ansible.png?s=28 :height: 28
.. |asitop-logo| image:: https://github.com/tlkh.png?s=28 :height: 28
.. |auto-cpufreq-logo| image:: https://github.com/AdnanHodzic.png?s=28 :height: 28
.. |bpytop-logo| image:: https://github.com/aristocratos.png?s=28 :height: 28
.. |celery-logo| image:: https://github.com/celery.png?s=28 :height: 28
.. |dask-logo| image:: https://github.com/dask.png?s=28 :height: 28
.. |ddtrace-logo| image:: https://github.com/DataDog.png?s=28 :height: 28
.. |dd-agent-logo| image:: https://github.com/DataDog.png?s=28 :height: 28
.. |glances-logo| image:: https://github.com/nicolargo.png?s=28 :height: 28
.. |grr-logo| image:: https://github.com/google.png?s=28 :height: 28
.. |homeassistant-logo| image:: https://github.com/home-assistant.png?s=28 :height: 28
.. |locust-logo| image:: https://github.com/locustio.png?s=28 :height: 28
.. |mlflow-logo| image:: https://github.com/mlflow.png?s=28 :height: 28
.. |osquery-logo| image:: https://github.com/osquery.png?s=28 :height: 28
.. |psdash-logo| image:: https://github.com/Jahaja.png?s=28 :height: 28
.. |psleak-logo| image:: https://github.com/giampaolo.png?s=28 :height: 28
.. |pytorch-logo| image:: https://github.com/pytorch.png?s=28 :height: 28
.. |ray-logo| image:: https://github.com/ray-project.png?s=28 :height: 28
.. |salt-logo| image:: https://github.com/saltstack.png?s=28 :height: 28
.. |sentry-logo| image:: https://github.com/getsentry.png?s=28 :height: 28
.. |spyder-logo| image:: https://github.com/spyder-ide.png?s=28 :height: 28
.. |stui-logo| image:: https://github.com/amanusk.png?s=28 :height: 28
.. |tensorflow-logo| image:: https://github.com/tensorflow.png?s=28 :height: 28

.. --- Notes
.. Stars shield:
.. https://shields.io/badges/git-hub-repo-stars


================================================
FILE: docs/alternatives.rst
================================================
.. currentmodule:: psutil

Alternatives
============

This page describes Python tools and modules that overlap with psutil,
to help you pick the right tool for the job.
See also :doc:`adoption` for notable projects that use psutil.

Python standard library
-----------------------

os module
^^^^^^^^^

The :mod:`os` module provides a handful of process-related functions:
:func:`os.getpid`, :func:`os.getppid`, :func:`os.getuid`,
:func:`os.cpu_count`, :func:`os.getloadavg` (UNIX only). These are
cheap wrappers around POSIX syscalls and are perfectly fine when you
only need information about the *current* process and don't need
cross-platform code.

psutil goes further in several directions. Its primary goal is to provide a
**single portable interface** for concepts that are natively UNIX-only. Things
like process CPU and memory usage, open file descriptors, network connections,
signals, nice levels, and I/O counters exist as first-class OS primitives on
Linux and macOS, but have no direct equivalent on Windows. psutil implements
all of them on Windows too (using Win32 APIs, ``NtQuerySystemInformation`` and
WMI) so that code written against psutil runs unmodified on every supported
platform. Beyond portability, it also exposes the same information for *any*
process (not just the current one), and returns structured named tuples instead
of raw integers.

resource module
^^^^^^^^^^^^^^^

:mod:`resource` (UNIX only) lets you read and set resource limits
(``RLIMIT_*``) and get basic usage counters (user/system time, page
faults, I/O ops) for the *current* process or its children via
:func:`resource.getrusage`. It is the right tool when you specifically
want to enforce or inspect ``ulimit``-style limits.

psutil's :meth:`Process.rlimit` exposes the same interface but extends it
to all processes, not just the caller.

subprocess module
^^^^^^^^^^^^^^^^^

Calling ``ps``, ``top``, ``netstat``, ``vmstat`` via
:mod:`subprocess` and parsing the text output is fragile: output
formats differ across OS versions and locales, parsing is error-prone,
and spawning a subprocess per sample is slow. psutil reads the same
kernel data sources directly without spawning any external processes.

platform module
^^^^^^^^^^^^^^^

:mod:`platform` provides information about the OS and Python runtime,
such as OS name, kernel version, architecture, and machine type.
It is useful for identifying the environment, but does not expose
runtime metrics or process information like psutil. Overlaps with
psutil's OS constants (:data:`LINUX`, :data:`WINDOWS`, :data:`MACOS`,
etc.).

/proc filesystem
^^^^^^^^^^^^^^^^

On Linux, ``/proc`` exposes process and system information as virtual files.
Reading ``/proc/pid/status`` or ``/proc/meminfo`` directly is fast and has no
dependencies, which is why some minimal containers or scripts do this. The
downsides are that it is Linux-only, the format may vary across kernel
versions, and you have to parse raw text yourself. psutil parses ``/proc``
internally, exposes the same information through a consistent
cross-platform API and handles edge cases (numeric overflow, compatibility
with old kernels, graceful fallbacks, etc.) transparently.

Third-party libraries
---------------------

Libraries that cover areas psutil does not, or that go deeper on a
specific platform or subsystem.

.. list-table::
   :header-rows: 1
   :widths: 5 25
   :class: longtable

   * - Library
     - Focus

   * - `distro <https://github.com/python-distro/distro>`_
     - Linux distro info (name, version, codename). psutil does not
       expose OS details.

   * - `GPUtil <https://github.com/anderskm/gputil>`_ /
       `pynvml <https://github.com/gpuopenanalytics/pynvml>`_
     - NVIDIA GPU utilization and VRAM usage.

   * - `ifaddr <https://github.com/ifaddr/ifaddr>`_
     - Network interface address enumeration.
       Overlaps with :func:`net_if_addrs`.

   * - `libvirt-python <https://github.com/libvirt/libvirt-python>`_
     - Manage KVM/QEMU/Xen VMs: enumerate guests, query
       CPU/memory allocation. Complements psutil's host-level view.

   * - `prometheus_client <https://github.com/prometheus/client_python>`_
     - Export metrics to Prometheus. Use *alongside* psutil.

   * - `py-cpuinfo <https://github.com/workhorsy/py-cpuinfo>`_
     - CPU brand string, microarchitecture, feature flags.

   * - `pyroute2 <https://github.com/svinota/pyroute2>`_
     - Linux netlink (interfaces, routes, connections).
       Overlaps with :func:`net_if_addrs`, :func:`net_if_stats`,
       :func:`net_connections`.

   * - `pywifi <https://github.com/awkman/pywifi>`_
     - WiFi scanning, signal strength, SSID. Exposes wireless
       details that :func:`net_if_addrs` does not.

   * - `pySMART <https://github.com/truenas/py-SMART>`_
     - S.M.A.R.T. disk health data. Complements
       :func:`disk_io_counters`.

   * - `pywin32 <https://github.com/mhammond/pywin32>`_
     - Win32 API bindings (Windows only).

   * - `setproctitle <https://github.com/dvarrazzo/py-setproctitle>`_
     - Set process title shown by ``ps``/``top``. Writes what
       :meth:`Process.name` reads.

   * - `wmi <https://github.com/tjguk/wmi>`_
     - WMI interface (Windows only).

Other languages
---------------

Equivalent libraries in other languages providing cross-platform system and
process information.

.. list-table::
   :header-rows: 1
   :widths: 5 5 20
   :class: longtable

   * - Library
     - Language
     - Focus

   * - `gopsutil <https://github.com/shirou/gopsutil>`_
     - Go
     - CPU, memory, disk, network, processes. Directly inspired
       by psutil and follows a similar API.

   * - `Hardware.Info <https://github.com/Jinjinov/Hardware.Info>`_
     - C# / .NET
     - CPU, RAM, GPU, disk, network, battery.

   * - `hwinfo <https://github.com/lfreist/hwinfo>`_
     - C++
     - CPU, RAM, GPU, disks, mainboard. More hardware-focused.

   * - `OSHI <https://github.com/oshi/oshi>`_
     - Java
     - OS and hardware information: CPU, memory, disk, network,
       processes, sensors, USB devices.

   * - `sysinfo <https://github.com/GuillaumeGomez/sysinfo>`_
     - Rust
     - CPU, memory, disk, network, processes, components.

   * - `systeminformation <https://github.com/sebhildebrandt/systeminformation>`_
     - Node.js
     - CPU, memory, disk, network, processes, battery, Docker.


================================================
FILE: docs/api.rst
================================================
.. currentmodule:: psutil
.. include:: _links.rst
.. _availability:

API reference
=============

.. note::
   psutil 8.0 introduces breaking API changes. See the
   :ref:`migration guide <migration-8.0>` if upgrading from 7.x.

.. contents::
   :local:
   :depth: 5

System related functions
------------------------

CPU
^^^

.. function:: cpu_times(percpu=False)

  Return system CPU times as a named tuple. All fields are
  :term:`cumulative counters <cumulative counter>` (seconds) representing time
  the CPU has spent in each mode since boot.
  The attributes availability varies depending on the platform.
  Cross-platform fields:

  - **user**: time spent by normal processes executing in user mode; on Linux
    this also includes **guest** time

  - **system**: time spent by processes executing in kernel mode

  - **idle**: time spent doing nothing

  Platform-specific fields:

  - **nice** *(Linux, macOS, BSD)*: time spent by :term:`niced <nice>`
    (lower-priority) processes executing in user mode; on Linux this also
    includes **guest_nice** time.

  - **iowait** *(Linux, SunOS, AIX)*: time spent waiting for I/O to complete
    (:term:`iowait`). This is *not* accounted in **idle** time counter.

  - **irq** *(Linux, Windows, BSD)*: time spent for servicing
    :term:`hardware interrupts <hardware interrupt>`

  - **softirq** *(Linux)*: time spent for servicing
    :term:`soft interrupts <soft interrupt>`

  - **steal** *(Linux)*: CPU time the virtual machine wanted to run but was
    used by other virtual machines or the host. A sustained non-zero steal rate
    indicates CPU contention.

  - **guest** *(Linux)*: time the host CPU spent running a guest operating
    system (virtual machine). Already included in **user** time.

  - **guest_nice** *(Linux)*: like **guest**, but for virtual CPUs running at a
    lower :term:`nice` priority. Already included in **nice** time.

  - **dpc** *(Windows)*: time spent servicing deferred procedure calls (DPCs);
    DPCs are interrupts that run at a lower priority than standard interrupts.

  When *percpu* is ``True`` return a list of named tuples for each logical CPU
  on the system.
  The list is ordered by CPU index.
  The order of the list is consistent across calls.
  Example output on Linux:

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.cpu_times()
     scputimes(user=17411.7, system=3797.02, idle=51266.57, nice=77.99, iowait=732.58, irq=0.01, softirq=142.43, steal=0.0, guest=0.0, guest_nice=0.0)

  .. note::
    CPU times are always supposed to increase over time, or at least remain the
    same, and that's because time cannot go backwards. Surprisingly sometimes
    this might not be the case (at least on Windows and Linux), see `#1210
    <https://github.com/giampaolo/psutil/issues/1210#issuecomment-363046156>`_.

  .. versionchanged:: 4.1.0
     added *irq* and *dpc* fields on Windows (*irq* was called *interrupt*
     before 8.0.0).

  .. versionchanged:: 8.0.0
     *interrupt* field on Windows was renamed to *irq*; *interrupt* still
     works but raises :exc:`DeprecationWarning`.

  .. versionchanged:: 8.0.0
     ``cpu_times()`` field order was standardized: ``user``, ``system``,
     ``idle`` are now always the first three fields. Previously on Linux,
     macOS, and BSD the first three were ``user``, ``nice``, ``system``.
     See :ref:`migration guide <migration-8.0>`.

.. function:: cpu_percent(interval=None, percpu=False)

  Return a float representing the current system-wide CPU utilization as a
  percentage. When *interval* is > ``0.0`` compares system CPU times elapsed
  before and after the interval (blocking).
  When *interval* is ``0.0`` or ``None`` compares system CPU times elapsed
  since last call or module import, returning immediately.
  That means the first time this is called it will return a meaningless ``0.0``
  value which you are supposed to ignore.
  In this case it is recommended for accuracy that this function be called with
  at least ``0.1`` seconds between calls.
  When *percpu* is ``True`` returns a list of floats representing the
  utilization as a percentage for each CPU.
  The list is ordered by CPU index. The order of the list is consistent across
  calls.
  Internally this function maintains a global map (a dict) where each key is
  the ID of the calling thread (:func:`threading.get_ident`). This means it can be
  called from different threads, at different intervals, and still return
  meaningful and independent results.

  .. code-block:: pycon

     >>> import psutil
     >>> # blocking
     >>> psutil.cpu_percent(interval=1)
     2.0
     >>> # non-blocking (percentage since last call)
     >>> psutil.cpu_percent(interval=None)
     2.9
     >>> # blocking, per-cpu
     >>> psutil.cpu_percent(interval=1, percpu=True)
     [2.0, 1.0]
     >>>

  .. note::
    the first time this function is called with *interval* = ``0.0`` or ``None``
    it will return a meaningless ``0.0`` value which you are supposed to
    ignore. See also :ref:`faq_cpu_percent` FAQ.

  .. versionchanged:: 5.9.6
     the function is now thread safe.

.. function:: cpu_times_percent(interval=None, percpu=False)

  Same as :func:`cpu_percent` but provides utilization percentages for each
  specific CPU time as is returned by
  :func:`psutil.cpu_times(percpu=True)<cpu_times()>`.
  *interval* and
  *percpu* arguments have the same meaning as in :func:`cpu_percent`.
  On Linux "guest" and "guest_nice" percentages are not accounted in "user"
  and "user_nice" percentages.

  .. note::
    the first time this function is called with *interval* = ``0.0`` or
    ``None`` it will return a meaningless ``0.0`` value which you are supposed
    to ignore. See also :ref:`faq_cpu_percent` FAQ.

  .. versionchanged:: 4.1.0
     two new *irq* and *dpc* fields are returned on Windows (*irq* was
     called *interrupt* before 8.0.0).

  .. versionchanged:: 5.9.6
     function is now thread safe.

.. function:: cpu_count(logical=True)

  Return the number of :term:`logical CPUs <logical CPU>` in the system
  (similar to :func:`os.cpu_count`) or ``None`` if undetermined.
  Unlike :func:`os.cpu_count`, this is not influenced by the ``PYTHON_CPU_COUNT``
  environment variable introduced in Python 3.13.
  "logical CPUs" means the number of physical cores multiplied by the number
  of threads that can run on each core (this is known as Hyper Threading).
  This is what cloud providers often refer to as vCPUs.
  If *logical* is ``False`` return the number of physical cores only, or
  ``None`` if undetermined.
  On OpenBSD and NetBSD ``psutil.cpu_count(logical=False)`` always return
  ``None``.
  Example on a system having 2 cores + Hyper Threading:

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.cpu_count()
     4
     >>> psutil.cpu_count(logical=False)
     2

  Note that ``psutil.cpu_count()`` may not necessarily be equivalent to the
  actual number of CPUs the current process can use.
  That can vary in case process CPU affinity has been changed, Linux cgroups
  are being used or (in case of Windows) on systems using processor groups or
  having more than 64 CPUs.
  The number of usable CPUs can be obtained with:

  .. code-block:: pycon

     >>> len(psutil.Process().cpu_affinity())
     1

.. function:: cpu_stats()

  Return various CPU statistics as a named tuple. All fields are
  :term:`cumulative counters <cumulative counter>` since boot.

  - **ctx_switches**: number of :term:`context switches <context switch>`
    (voluntary + involuntary).
  - **interrupts**:
    number of :term:`hardware interrupts <hardware interrupt>`.
  - **soft_interrupts**:
    number of :term:`soft interrupts <soft interrupt>`. Always set to ``0`` on
    Windows and SunOS.
  - **syscalls**: number of system calls. Always set to ``0`` on Linux.

  Example (Linux):

  .. code-block:: python

     >>> import psutil
     >>> psutil.cpu_stats()
     scpustats(ctx_switches=20455687, interrupts=6598984, soft_interrupts=2134212, syscalls=0)

  .. versionadded:: 4.1.0


.. function:: cpu_freq(percpu=False)

    Return CPU frequency as a named tuple including *current*, *min* and *max*
    frequencies expressed in Mhz. On Linux *current* frequency reports the
    real-time value, on all other platforms this usually represents the
    nominal "fixed" value (never changing). If *percpu* is ``True`` and the
    system supports per-cpu frequency retrieval (Linux and FreeBSD), a list of
    frequencies is returned for each CPU, if not, a list with a single element
    is returned. If *min* and *max* cannot be determined they are set to
    ``0.0``.

    Example (Linux):

    .. code-block:: python

       >>> import psutil
       >>> psutil.cpu_freq()
       scpufreq(current=931.42925, min=800.0, max=3500.0)
       >>> psutil.cpu_freq(percpu=True)
       [scpufreq(current=2394.945, min=800.0, max=3500.0),
        scpufreq(current=2236.812, min=800.0, max=3500.0),
        scpufreq(current=1703.609, min=800.0, max=3500.0),
        scpufreq(current=1754.289, min=800.0, max=3500.0)]

    .. availability:: Linux, macOS, Windows, FreeBSD, OpenBSD.

    .. versionadded:: 5.1.0

    .. versionchanged:: 5.5.1
       added FreeBSD support.

    .. versionchanged:: 5.9.1
       added OpenBSD support.

.. function:: getloadavg()

    Return the average system load over the last 1, 5 and 15 minutes as a tuple.
    The "load" represents the processes which are in a runnable state, either
    using the CPU or waiting to use the CPU (e.g. waiting for disk I/O).
    On UNIX systems this relies on :func:`os.getloadavg`. On Windows this is emulated
    by using a Windows API that spawns a thread which keeps running in
    background and updates results every 5 seconds, mimicking the UNIX behavior.
    Thus, on Windows, the first time this is called and for the next 5 seconds
    it will return a meaningless ``(0.0, 0.0, 0.0)`` tuple.
    The numbers returned only make sense when compared to the number of CPU cores
    installed on the system. So, for instance, a value of `3.14` on a system
    with 10 logical CPUs means that the system load was 31.4% percent over the
    last N minutes.

    .. code-block:: python

       >>> import psutil
       >>> psutil.getloadavg()
       (3.14, 3.89, 4.67)
       >>> psutil.cpu_count()
       10
       >>> # percentage representation
       >>> [x / psutil.cpu_count() * 100 for x in psutil.getloadavg()]
       [31.4, 38.9, 46.7]

    .. versionadded:: 5.6.2

Memory
^^^^^^

.. function:: virtual_memory()

  Return statistics about system memory usage as a named tuple including the
  following fields, expressed in bytes.

  - **total**: total physical memory (exclusive swap).
  - **available**: memory that can be given instantly to processes without the
    system going into swap. On Linux it uses the ``MemAvailable`` field from
    ``/proc/meminfo`` *(kernel 3.14+)*; on older kernels it falls back to an
    estimate. This is the recommended field for monitoring actual memory usage
    in a cross-platform fashion. See :term:`available memory`.
  - **percent**: the percentage usage calculated as
    ``(total - available) / total * 100``.
  - **used**: memory in use, calculated differently depending on the platform
    (see the table below). It is meant for informational purposes. Neither
    ``total - free`` nor ``total - available`` necessarily equals ``used``.
  - **free**: memory not currently allocated to anything. This is
    typically much lower than **available** because the OS keeps recently
    freed memory as reclaimable cache (see **cached** and **buffers**)
    rather than zeroing it immediately. Do not use this to check for
    memory pressure; use **available** instead.
  - **active** *(Linux, macOS, BSD)*: memory currently mapped by processes
    or recently accessed, held in RAM. It is unlikely to be reclaimed unless
    the system is under significant memory pressure.
  - **inactive** *(Linux, macOS, BSD)*: memory not recently accessed. It
    still holds valid data (:term:`page cache`, old allocations) but is a
    candidate for reclamation or swapping. On BSD systems it is counted in
    **available**.
  - **buffers** *(Linux, BSD)*: memory used by the kernel to cache disk
    metadata (e.g. filesystem structures). Reclaimable by the OS when needed.
  - **cached** *(Linux, BSD, Windows)*: RAM used by the kernel to cache file
    contents (data read from or written to disk). Reclaimable by the OS when
    needed. See :term:`page cache`.
  - **shared** *(Linux, BSD)*: memory accessible by multiple processes
    simultaneously, such as in-memory ``tmpfs`` and POSIX shared memory objects
    (``shm_open``). On Linux this corresponds to ``Shmem`` in ``/proc/meminfo``
    and is already counted within **active** / **inactive**.
  - **slab** *(Linux)*: memory used by the kernel's internal object caches
    (e.g. inode and dentry caches). The reclaimable portion
    (``SReclaimable``) is already included in **cached**.
  - **wired** *(macOS, BSD, Windows)*: memory pinned in RAM by the kernel (e.g.
    kernel code and critical data structures). It can never be moved to disk.

  Below is a table showing implementation details. All info on Linux is
  retrieved from `/proc/meminfo`_. On macOS via ``host_statistics64()``. On
  Windows via `GetPerformanceInfo`_.

  .. list-table::
     :header-rows: 1
     :widths: 9 15 14 14 26

     * - Field
       - Linux
       - macOS
       - Windows
       - FreeBSD
     * - total
       - ``MemTotal``
       - ``sysctl() hw.memsize``
       - ``PhysicalTotal``
       - ``sysctl() hw.physmem``
     * - available
       - ``MemAvailable``
       - ``inactive + free``
       - ``PhysicalAvailable``
       - ``inactive + cached + free``
     * - used
       - ``total - available``
       - ``active + wired``
       - ``total - available``
       - ``active + wired + cached``
     * - free
       - ``MemFree``
       - ``free - speculative``
       - same as ``available``
       - ``sysctl() vm.stats.vm.v_free_count``
     * - active
       - ``Active``
       - ``active``
       -
       - ``sysctl() vm.stats.vm.v_active_count``
     * - inactive
       - ``Inactive``
       - ``inactive``
       -
       - ``sysctl() vm.stats.vm.v_inactive_count``
     * - buffers
       - ``Buffers``
       -
       -
       - ``sysctl() vfs.bufspace``
     * - cached
       - ``Cached + SReclaimable``
       -
       - ``SystemCache``
       - ``sysctl() vm.stats.vm.v_cache_count``
     * - shared
       - ``Shmem``
       -
       -
       - ``sysctl(CTL_VM/VM_METER) t_vmshr + t_rmshr``
     * - slab
       - ``Slab``
       -
       -
       -
     * - wired
       -
       - ``wired``
       - ``KernelNonpaged``
       - ``sysctl() vm.stats.vm.v_wire_count``

  Example on Linux:

  .. code-block:: pycon

     >>> import psutil
     >>> mem = psutil.virtual_memory()
     >>> mem
     svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304, slab=199348224)
     >>>
     >>> THRESHOLD = 500 * 1024 * 1024  # 500MB
     >>> if mem.available <= THRESHOLD:
     ...     print("warning")
     ...
     >>>

  .. note:: if you just want to know how much physical memory is left in a
    cross-platform manner, simply rely on **available** and **percent**
    fields.

  .. note::
     - On Linux, **total**, **free**, **used**, **shared**, and **available**
       match the output of the ``free`` command.
     - On macOS, **free**, **active**, **inactive**, and **wired** match
       ``vm_stat`` output.
     - On Windows, **total**, **used** ("In use"), and **available** match
       the Task Manager (Performance > Memory tab).

  .. note::  see also `scripts/meminfo.py`_.

  .. versionchanged:: 4.2.0
     added *shared* metric on Linux.

  .. versionchanged:: 5.4.4
     added *slab* metric on Linux.

  .. versionchanged:: 8.0.0
     added *cached* and *wired* metric on Windows.

.. function:: swap_memory()

  Return system swap memory statistics as a named tuple including the following
  fields:

  * **total**: total swap space. On Windows this is derived as
    ``CommitLimit - PhysicalTotal``, representing virtual memory backed by
    the page file rather than the raw page-file size.
  * **used**: swap space currently in use.
  * **free**: swap space not in use (``total - used``).
  * **percent**: swap usage as a percentage, calculated as
    ``used / total * 100``.
  * **sin**: number of bytes the system has paged *in* from disk (pages moved
    from swap space back into RAM) since boot. See :term:`swap-in`.
  * **sout**: number of bytes the system has paged *out* to disk (pages moved
    from RAM into swap space) since boot. A continuously increasing **sout**
    is a sign of memory pressure. See :term:`swap-out`.

  **sin** and **sout** are :term:`cumulative counters <cumulative counter>` since boot; monitor
  their rate of change rather than the absolute value to detect active
  swapping. See :term:`swap-in` and :term:`swap-out`.
  On Windows both are always ``0``.
  See `scripts/meminfo.py`_ script providing an example on how to convert bytes in a
  human readable form.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.swap_memory()
     sswap(total=2097147904L, used=886620160L, free=1210527744L, percent=42.3, sin=1050411008, sout=1906720768)

  .. versionchanged:: 5.2.3
     on Linux this function relies on /proc fs instead of sysinfo() syscall so
     that it can be used in conjunction with
     :const:`psutil.PROCFS_PATH` in order to retrieve memory info about
     Linux containers such as Docker and Heroku.

Disks
^^^^^

.. function:: disk_partitions(all=False)

  Return all mounted disk partitions as a list of named tuples including device,
  mount point and filesystem type, similarly to "df" command on UNIX. If *all*
  parameter is ``False`` it tries to distinguish and return physical devices
  only (e.g. hard disks, cd-rom drives, USB keys) and ignore all others
  (e.g. pseudo, memory, duplicate, inaccessible filesystems).
  Note that this may not be fully reliable on all systems (e.g. on BSD this
  parameter is ignored).
  See `scripts/disk_usage.py`_ script providing an example usage.
  Returns a list of named tuples with the following fields:

  * **device**: the device path (e.g. ``"/dev/hda1"``). On Windows this is the
    drive letter (e.g. ``"C:\\"``).
  * **mountpoint**: the mount point path (e.g. ``"/"``). On Windows this is the
    drive letter (e.g. ``"C:\\"``).
  * **fstype**: the partition filesystem (e.g. ``"ext3"`` on UNIX or ``"NTFS"``
    on Windows).
  * **opts**: a comma-separated string indicating different mount options for
    the drive/partition. Platform-dependent.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.disk_partitions()
     [sdiskpart(device='/dev/sda3', mountpoint='/', fstype='ext4', opts='rw,errors=remount-ro'),
      sdiskpart(device='/dev/sda7', mountpoint='/home', fstype='ext4', opts='rw')]

  .. versionchanged:: 5.7.4
     added *maxfile* and *maxpath* fields.

  .. versionchanged:: 6.0.0
     removed *maxfile* and *maxpath* fields.

.. function:: disk_usage(path)

  Return disk usage statistics about the partition which contains the given
  *path* as a named tuple including **total**, **used** and **free** space
  expressed in bytes, plus the **percentage** usage.
  ``OSError`` is raised if *path* does not exist.
  Starting from Python 3.3 this is also available as :func:`shutil.disk_usage`
  (see `BPO-12442`_).
  See `scripts/disk_usage.py`_ script providing an example usage.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.disk_usage('/')
     sdiskusage(total=21378641920, used=4809781248, free=15482871808, percent=22.5)

  .. note::
    UNIX usually reserves 5% of the total disk space for the root user.
    *total* and *used* fields on UNIX refer to the overall total and used
    space, whereas *free* represents the space available for the **user** and
    *percent* represents the **user** utilization (see
    `source code <https://github.com/giampaolo/psutil/blob/3dea30d583b8c1275057edb1b3b720813b4d0f60/psutil/_psposix.py#L123>`_).
    That is why *percent* value may look 5% bigger than what you would expect
    it to be.
    Also note that both 4 values match "df" cmdline utility.

  .. versionchanged:: 4.3.0
     *percent* value takes root reserved space into account.

.. function:: disk_io_counters(perdisk=False, nowrap=True)

  Return system-wide disk I/O statistics as a named tuple including the
  following fields:

  - **read_count**: number of reads
  - **write_count**: number of writes
  - **read_bytes**: number of bytes read
  - **write_bytes**: number of bytes written

  Platform-specific fields:

  - **read_time**: (all except *NetBSD* and *OpenBSD*) time spent reading from
    disk (in milliseconds)
  - **write_time**: (all except *NetBSD* and *OpenBSD*) time spent writing to disk
    (in milliseconds)
  - **busy_time**: (*Linux*, *FreeBSD*) time spent doing actual I/Os (in
    milliseconds). See :term:`busy_time`.
  - **read_merged_count** (*Linux*): number of merged reads (see `iostats doc`_)
  - **write_merged_count** (*Linux*): number of merged writes (see `iostats doc`_)

  If *perdisk* is ``True`` return the same information for every physical disk
  installed on the system as a dictionary with partition names as the keys and
  the named tuple described above as the values.
  See `scripts/iotop.py`_ for an example application.
  On some systems such as Linux, on a very busy or long-lived system, the
  numbers returned by the kernel may overflow and wrap (restart from zero).
  If *nowrap* is ``True`` psutil will detect and adjust those numbers across
  function calls and add "old value" to "new value" so that the returned
  numbers will always be increasing or remain the same, but never decrease.
  ``disk_io_counters.cache_clear()`` can be used to invalidate the *nowrap*
  cache.
  On Windows it may be necessary to issue ``diskperf -y`` command from cmd.exe
  first in order to enable IO counters.
  On diskless machines this function will return ``None`` or ``{}`` if
  *perdisk* is ``True``.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.disk_io_counters()
     sdiskio(read_count=8141, write_count=2431, read_bytes=290203, write_bytes=537676, read_time=5868, write_time=94922)
     >>>
     >>> psutil.disk_io_counters(perdisk=True)
     {'sda1': sdiskio(read_count=920, write_count=1, read_bytes=2933248, write_bytes=512, read_time=6016, write_time=4),
      'sda2': sdiskio(read_count=18707, write_count=8830, read_bytes=6060, write_bytes=3443, read_time=24585, write_time=1572),
      'sdb1': sdiskio(read_count=161, write_count=0, read_bytes=786432, write_bytes=0, read_time=44, write_time=0)}

  .. note::
    on Windows ``"diskperf -y"`` command may need to be executed first
    otherwise this function won't find any disk.

  .. versionchanged:: 5.3.0
     numbers no longer wrap (restart from zero) across calls thanks to new
    *nowrap* argument.

  .. versionchanged:: 4.0.0
     added *busy_time* (Linux, FreeBSD), *read_merged_count* and
    *write_merged_count* (Linux) fields.

  .. versionchanged:: 4.0.0
     NetBSD no longer has *read_time* and *write_time* fields.

Network
^^^^^^^

.. function:: net_io_counters(pernic=False, nowrap=True)

  Return system-wide network I/O statistics as a named tuple including the
  following attributes:

  - **bytes_sent**: number of bytes sent
  - **bytes_recv**: number of bytes received
  - **packets_sent**: number of packets sent
  - **packets_recv**: number of packets received
  - **errin**: total number of errors while receiving
  - **errout**: total number of errors while sending
  - **dropin**: total number of incoming packets which were dropped
  - **dropout**: total number of outgoing packets which were dropped (always 0
    on macOS and BSD). See :term:`dropin / dropout`.

  If *pernic* is ``True`` return the same information for every network
  interface installed on the system as a dictionary with network interface
  names as the keys and the named tuple described above as the values.
  On some systems such as Linux, on a very busy or long-lived system, the
  numbers returned by the kernel may overflow and wrap (restart from zero).
  If *nowrap* is ``True`` psutil will detect and adjust those numbers across
  function calls and add "old value" to "new value" so that the returned
  numbers will always be increasing or remain the same, but never decrease.
  ``net_io_counters.cache_clear()`` can be used to invalidate the *nowrap*
  cache.
  On machines with no network interfaces this function will return ``None`` or
  ``{}`` if *pernic* is ``True``.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.net_io_counters()
     snetio(bytes_sent=14508483, bytes_recv=62749361, packets_sent=84311, packets_recv=94888, errin=0, errout=0, dropin=0, dropout=0)
     >>>
     >>> psutil.net_io_counters(pernic=True)
     {'lo': snetio(bytes_sent=547971, bytes_recv=547971, packets_sent=5075, packets_recv=5075, errin=0, errout=0, dropin=0, dropout=0),
     'wlan0': snetio(bytes_sent=13921765, bytes_recv=62162574, packets_sent=79097, packets_recv=89648, errin=0, errout=0, dropin=0, dropout=0)}

  Also see `scripts/nettop.py`_ and `scripts/ifconfig.py`_ for an example application.

  .. versionchanged:: 5.3.0
     numbers no longer wrap (restart from zero) across calls thanks to new
     *nowrap* argument.

.. function:: net_connections(kind='inet')

  Return system-wide socket connections as a list of named tuples.
  Every named tuple provides 7 attributes:

  - **fd**: the socket file descriptor. If the connection refers to the current
    process this may be passed to :func:`socket.fromfd`
    to obtain a usable socket object.
    On Windows and SunOS this is always set to ``-1``.
  - **family**: the address family, either :data:`socket.AF_INET`, :data:`socket.AF_INET6` or :data:`socket.AF_UNIX`.
  - **type**: the address type, either :data:`socket.SOCK_STREAM`, :data:`socket.SOCK_DGRAM` or
    :data:`socket.SOCK_SEQPACKET`.
  - **laddr**: the local address as a ``(ip, port)`` named tuple or a ``path``
    in case of AF_UNIX sockets. For UNIX sockets see notes below.
  - **raddr**: the remote address as a ``(ip, port)`` named tuple or an
    absolute ``path`` in case of UNIX sockets.
    When the remote endpoint is not connected you'll get an empty tuple
    (AF_INET*) or ``""`` (AF_UNIX). For UNIX sockets see notes below.
  - **status**: represents the status of a TCP connection. The return value
    is one of the `psutil.CONN_* <#connections-constants>`_ constants
    (a string).
    For UDP and UNIX sockets this is always going to be
    :const:`psutil.CONN_NONE`.
  - **pid**: the PID of the process which opened the socket, if retrievable,
    else ``None``. On some platforms (e.g. Linux) the availability of this
    field changes depending on process privileges (root is needed).

  The *kind* parameter is a string which filters for connections matching the
  following criteria:

  .. table::

   +----------------+-----------------------------------------------------+
   | Kind value     | Connections using                                   |
   +================+=====================================================+
   | ``"inet"``     | IPv4 and IPv6                                       |
   +----------------+-----------------------------------------------------+
   | ``"inet4"``    | IPv4                                                |
   +----------------+-----------------------------------------------------+
   | ``"inet6"``    | IPv6                                                |
   +----------------+-----------------------------------------------------+
   | ``"tcp"``      | TCP                                                 |
   +----------------+-----------------------------------------------------+
   | ``"tcp4"``     | TCP over IPv4                                       |
   +----------------+-----------------------------------------------------+
   | ``"tcp6"``     | TCP over IPv6                                       |
   +----------------+-----------------------------------------------------+
   | ``"udp"``      | UDP                                                 |
   +----------------+-----------------------------------------------------+
   | ``"udp4"``     | UDP over IPv4                                       |
   +----------------+-----------------------------------------------------+
   | ``"udp6"``     | UDP over IPv6                                       |
   +----------------+-----------------------------------------------------+
   | ``"unix"``     | UNIX socket (both UDP and TCP protocols)            |
   +----------------+-----------------------------------------------------+
   | ``"all"``      | the sum of all the possible families and protocols  |
   +----------------+-----------------------------------------------------+

  On macOS and AIX this function requires root privileges.
  To get per-process connections use :meth:`Process.net_connections`.
  Also, see `scripts/netstat.py`_ example script.
  Example:

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.net_connections()
     [pconn(fd=115, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=48776), raddr=addr(ip='93.186.135.91', port=80), status=<ConnectionStatus.CONN_ESTABLISHED: 'ESTABLISHED'>, pid=1254),
      pconn(fd=117, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=43761), raddr=addr(ip='72.14.234.100', port=80), status=<ConnectionStatus.CONN_CLOSING: 'CLOSING'>, pid=2987),
      pconn(fd=-1, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=60759), raddr=addr(ip='72.14.234.104', port=80), status=<ConnectionStatus.CONN_ESTABLISHED: 'ESTABLISHED'>, pid=None),
      pconn(fd=-1, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=addr(ip='10.0.0.1', port=51314), raddr=addr(ip='72.14.234.83', port=443), status=<ConnectionStatus.CONN_SYN_SENT: 'SYN_SENT'>, pid=None)
      ...]

  .. warning::
    On Linux, retrieving some connections requires root privileges. If psutil is
    not run as root, those connections are silently skipped instead of raising
    :exc:`PermissionError`. That means the returned list may be incomplete.

  .. note::
    (macOS and AIX) :exc:`psutil.AccessDenied` is always raised unless running
    as root. This is a limitation of the OS and ``lsof`` does the same.

  .. note::
    (Solaris) UNIX sockets are not supported.

  .. note::
     (Linux, FreeBSD, OpenBSD) *raddr* field for UNIX sockets is always set to
     ``""`` (empty string). This is a limitation of the OS.

  .. versionadded:: 2.1.0

  .. versionchanged:: 5.3.0
     socket "fd" is now set for real instead of being ``-1``.

  .. versionchanged:: 5.3.0
    *laddr* and *raddr* are named tuples.

  .. versionchanged:: 5.9.5
     OpenBSD: retrieve *laddr* path for AF_UNIX sockets (before it was an empty
     string).

  .. versionchanged:: 8.0.0
     *status* field is now a :class:`psutil.ConnectionStatus` enum member
     instead of a plain ``str``.
     See :ref:`migration guide <migration-8.0>`.

.. function:: net_if_addrs()

  Return the addresses associated to each :term:`NIC` (network interface card)
  installed on the system as a dictionary whose keys are the NIC names and
  value is a list of named tuples for each address assigned to the NIC.
  Each named tuple includes 5 fields:

  - **family**: the address family, either :data:`socket.AF_INET` or :data:`socket.AF_INET6`
    or :const:`psutil.AF_LINK`, which refers to a MAC address.
  - **address**: the primary NIC address (always set).
  - **netmask**: the netmask address (may be ``None``).
  - **broadcast**: the broadcast address (may be ``None``).
  - **ptp**: stands for "point to point"; it's the destination address on a
    point to point interface (typically a VPN). *broadcast* and *ptp* are
    mutually exclusive. May be ``None``.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.net_if_addrs()
     {'lo': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='127.0.0.1', netmask='255.0.0.0', broadcast='127.0.0.1', ptp=None),
             snicaddr(family=<AddressFamily.AF_INET6: 10>, address='::1', netmask='ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', broadcast=None, ptp=None),
             snicaddr(family=<AddressFamily.AF_LINK: 17>, address='00:00:00:00:00:00', netmask=None, broadcast='00:00:00:00:00:00', ptp=None)],
      'wlan0': [snicaddr(family=<AddressFamily.AF_INET: 2>, address='192.168.1.3', netmask='255.255.255.0', broadcast='192.168.1.255', ptp=None),
                snicaddr(family=<AddressFamily.AF_INET6: 10>, address='fe80::c685:8ff:fe45:641%wlan0', netmask='ffff:ffff:ffff:ffff::', broadcast=None, ptp=None),
                snicaddr(family=<AddressFamily.AF_LINK: 17>, address='c4:85:08:45:06:41', netmask=None, broadcast='ff:ff:ff:ff:ff:ff', ptp=None)]}
     >>>

  See also `scripts/nettop.py`_ and `scripts/ifconfig.py`_ for an example application.

  .. note::
    if you're interested in others families (e.g. AF_BLUETOOTH) you can use
    the more powerful `netifaces <https://pypi.org/project/netifaces/>`_
    extension.

  .. note::
    you can have more than one address of the same family associated with each
    interface (that's why dict values are lists).

  .. note::
    *broadcast* and *ptp* are not supported on Windows and are always ``None``.

  .. versionadded:: 3.0.0

  .. versionchanged:: 3.2.0
     *ptp* field was added.

  .. versionchanged:: 4.4.0
     added support for *netmask* field on Windows which is no longer ``None``.

  .. versionchanged:: 7.0.0
     added support for *broadcast* field on Windows which is no longer ``None``.

.. function:: net_if_stats()

  Return information about each :term:`NIC` (network interface card) installed on the
  system as a dictionary whose keys are the NIC names and value is a named tuple
  with the following fields:

  - **isup**: a bool indicating whether the NIC is up and running (meaning
    ethernet cable or Wi-Fi is connected).
  - **duplex**: the duplex communication type;
    it can be either :const:`NIC_DUPLEX_FULL`, :const:`NIC_DUPLEX_HALF` or
    :const:`NIC_DUPLEX_UNKNOWN`.
  - **speed**: the NIC speed expressed in megabits (Mbps), if it can't be
    determined (e.g. 'localhost') it will be set to ``0``.
  - **mtu**: NIC's maximum transmission unit expressed in bytes.
  - **flags**: a string of comma-separated flags on the interface (may be an empty string).
    Possible flags are: ``up``, ``broadcast``, ``debug``, ``loopback``,
    ``pointopoint``, ``notrailers``, ``running``, ``noarp``, ``promisc``,
    ``allmulti``, ``master``, ``slave``, ``multicast``, ``portsel``,
    ``dynamic``, ``oactive``, ``simplex``, ``link0``, ``link1``, ``link2``,
    and ``d2`` (some flags are only available on certain platforms).

  Also see `scripts/nettop.py`_ and `scripts/ifconfig.py`_ for an example application.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.net_if_stats()
     {'eth0': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_FULL: 2>, speed=100, mtu=1500, flags='up,broadcast,running,multicast'),
      'lo': snicstats(isup=True, duplex=<NicDuplex.NIC_DUPLEX_UNKNOWN: 0>, speed=0, mtu=65536, flags='up,loopback,running')}

  .. availability:: UNIX

  .. versionadded:: 3.0.0

  .. versionchanged:: 5.7.3
     `isup` on UNIX also checks whether the NIC is running.

  .. versionchanged:: 5.9.3
     *flags* field was added on POSIX.

Sensors
^^^^^^^

.. function:: sensors_temperatures(fahrenheit=False)

  Return hardware temperatures. Each entry is a named tuple representing a
  certain hardware temperature sensor (it may be a CPU, an hard disk or
  something else, depending on the OS and its configuration).
  All temperatures are expressed in celsius unless *fahrenheit* is set to
  ``True``.
  If sensors are not supported by the OS an empty dict is returned.
  Each named tuple includes 4 fields:

  - **label**: a string label for the sensor, if available, else ``""``.
  - **current**: current temperature, or ``None`` if not available.
  - **high**: temperature at which the system will throttle, or ``None``
    if not available.
  - **critical**: temperature at which the system will shut down, or
    ``None`` if not available.

  See also `scripts/temperatures.py`_ and `scripts/sensors.py`_ for an example application.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.sensors_temperatures()
     {'acpitz': [shwtemp(label='', current=47.0, high=103.0, critical=103.0)],
      'asus': [shwtemp(label='', current=47.0, high=None, critical=None)],
      'coretemp': [shwtemp(label='Physical id 0', current=52.0, high=100.0, critical=100.0),
                   shwtemp(label='Core 0', current=45.0, high=100.0, critical=100.0),
                   shwtemp(label='Core 1', current=52.0, high=100.0, critical=100.0),
                   shwtemp(label='Core 2', current=45.0, high=100.0, critical=100.0),
                   shwtemp(label='Core 3', current=47.0, high=100.0, critical=100.0)]}

  .. availability:: Linux, FreeBSD

  .. versionadded:: 5.1.0

  .. versionchanged:: 5.5.0
     added FreeBSD support.

.. function:: sensors_fans()

  Return hardware fans speed. Each entry is a named tuple representing a
  certain hardware sensor fan.
  Fan speed is expressed in RPM (revolutions per minute).
  If sensors are not supported by the OS an empty dict is returned.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.sensors_fans()
     {'asus': [sfan(label='cpu_fan', current=3200)]}

  See also `scripts/fans.py`_  and `scripts/sensors.py`_ for an example application.

  .. availability:: Linux

  .. versionadded:: 5.2.0

.. function:: sensors_battery()

  Return battery status information as a named tuple including the following
  values. If no battery is installed or metrics can't be determined ``None``
  is returned.

  - **percent**: battery power left as a percentage.
  - **secsleft**: a rough approximation of how many seconds are left before the
    battery runs out of power.
    If the AC power cable is connected this is set to
    :data:`psutil.POWER_TIME_UNLIMITED <psutil.POWER_TIME_UNLIMITED>`.
    If it can't be determined it is set to
    :data:`psutil.POWER_TIME_UNKNOWN <psutil.POWER_TIME_UNKNOWN>`.
  - **power_plugged**: ``True`` if the AC power cable is connected, ``False``
    if not or ``None`` if it can't be determined.

  .. code-block:: pycon

     >>> import psutil
     >>>
     >>> def secs2hours(secs):
     ...     mm, ss = divmod(secs, 60)
     ...     hh, mm = divmod(mm, 60)
     ...     return "%d:%02d:%02d" % (hh, mm, ss)
     ...
     >>> battery = psutil.sensors_battery()
     >>> battery
     sbattery(percent=93, secsleft=16628, power_plugged=False)
     >>> print("charge = %s%%, time left = %s" % (battery.percent, secs2hours(battery.secsleft)))
     charge = 93%, time left = 4:37:08

  See also `scripts/battery.py`_  and `scripts/sensors.py`_ for an example application.

  .. availability:: Linux, Windows, macOS, FreeBSD

  .. versionadded:: 5.1.0

  .. versionchanged:: 5.4.2
     added macOS support.

----

Other system info
^^^^^^^^^^^^^^^^^

.. function:: boot_time()

  Return the system boot time expressed in seconds since the epoch (seconds
  since January 1, 1970, at midnight UTC). The returned value is based on the
  system clock, which means it may be affected by changes such as manual
  adjustments or time synchronization (e.g. NTP).

  .. code-block:: python

     >>> import psutil, datetime
     >>> psutil.boot_time()
     1389563460.0
     >>> datetime.datetime.fromtimestamp(psutil.boot_time()).strftime("%Y-%m-%d %H:%M:%S")
     '2014-01-12 22:51:00'

  .. note::
    on Windows this function may return a time which is off by 1 second if it's
    used across different processes (see issue :gh:`1007`).

.. function:: users()

  Return users currently connected on the system as a list of named tuples
  including the following fields:

  - **name**: the name of the user.
  - **terminal**: the tty or pseudo-tty associated with the user, if any,
    else ``None``.
  - **host**: the host name associated with the entry, if any, else ``None``.
  - **started**: the creation time as a floating point number expressed in
    seconds since the epoch.
  - **pid**: the PID of the login process (like sshd, tmux, gdm-session-worker,
    ...). On Windows and OpenBSD this is always set to ``None``.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.users()
     [suser(name='giampaolo', terminal='pts/2', host='localhost', started=1340737536.0, pid=1352),
      suser(name='giampaolo', terminal='pts/3', host='localhost', started=1340737792.0, pid=1788)]

  .. versionchanged:: 5.3.0
     added "pid" field.

----

Processes
---------

Functions
^^^^^^^^^

.. function:: pids()

  Return a sorted list of current running PIDs.
  To iterate over all processes and avoid race conditions :func:`process_iter`
  should be preferred.

  .. code-block:: pycon

     >>> import psutil
     >>> psutil.pids()
     [1, 2, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, ..., 32498]


  .. versionchanged:: 5.6.0
     PIDs are returned in sorted order.

.. function:: process_iter(attrs=None, ad_value=None)

  Return an iterator yielding a :class:`Process` class instance for all running
  processes on the local machine.
  This should be preferred over :func:`psutil.pids` to iterate over
  processes, as retrieving info is safe from race conditions.

  Every :class:`Process` instance is only created once, and then cached for the
  next time :func:`psutil.process_iter` is called (if PID is still alive).
  Cache can optionally be cleared via ``process_iter.cache_clear()``.

  *attrs* and *ad_value* have the same meaning as in :meth:`Process.as_dict`.
  If *attrs* is specified :meth:`Process.as_dict` result will be stored as a
  ``info`` attribute attached to the returned :class:`Process` instances.
  If *attrs* is an empty list it will retrieve all process info (slow).

  Sorting order in which processes are returned is based on their PID.

  .. code-block:: pycon

     >>> import psutil
     >>> for proc in psutil.process_iter(['pid', 'name', 'username']):
     ...     print(proc.info)
     ...
     {'name': 'systemd', 'pid': 1, 'username': 'root'}
     {'name': 'kthreadd', 'pid': 2, 'username': 'root'}
     {'name': 'ksoftirqd/0', 'pid': 3, 'username': 'root'}
     ...

  A dict comprehensions to create a ``{pid: info, ...}`` data structure:

  .. code-block:: pycon

     >>> import psutil
     >>> procs = {p.pid: p.info for p in psutil.process_iter(['name', 'username'])}
     >>> procs
     {1: {'name': 'systemd', 'username': 'root'},
      2: {'name': 'kthreadd', 'username': 'root'},
      3: {'name': 'ksoftirqd/0', 'username': 'root'},
      ...}

  Clear internal cache:

  .. code-block:: pycon

     >>> psutil.process_iter.cache_clear()

  .. versionchanged:: 5.3.0
     added "attrs" and "ad_value" parameters.

  .. versionchanged:: 6.0.0
     no longer checks whether each yielded process PID has been reused.

  .. versionchanged:: 6.0.0
     added ``psutil.process_iter.cache_clear()`` API.

.. function:: pid_exists(pid)

  Check whether the given PID exists in the current process list. This is
  faster than doing ``pid in psutil.pids()`` and should be preferred.

.. function:: wait_procs(procs, timeout=None, callback=None)

  Convenience function which waits for a list of :class:`Process` instances to
  terminate. Return a ``(gone, alive)`` tuple indicating which processes are
  gone and which ones are still alive. The *gone* ones will have a new
  *returncode* attribute indicating process exit status as returned by
  :meth:`Process.wait`.
  ``callback`` is a function which gets called when one of the processes being
  waited on is terminated and a :class:`Process` instance is passed as callback
  argument (the instance will also have a *returncode* attribute set).
  This function will return as soon as all processes terminate or when
  *timeout* (seconds) occurs.
  Differently from :meth:`Process.wait` it will not raise
  :exc:`TimeoutExpired` if timeout occurs.
  A typical use case may be:

  - send SIGTERM to a list of processes
  - give them some time to terminate
  - send SIGKILL to those ones which are still alive

  Example which terminates and waits all the children of this process::

    import psutil

    def on_terminate(proc):
        print("process {} terminated with exit code {}".format(proc, proc.returncode))

    procs = psutil.Process().children()
    for p in procs:
        p.terminate()
    gone, alive = psutil.wait_procs(procs, timeout=3, callback=on_terminate)
    for p in alive:
        p.kill()

Exceptions
^^^^^^^^^^

.. exception:: Error()

  Base exception class. All other exceptions inherit from this one.

.. exception:: NoSuchProcess(pid, name=None, msg=None)

  Raised by :class:`Process` class methods when no process with the given
  *pid* is found in the current process list, or when a process no longer
  exists. *name* is the name the process had before disappearing
  and gets set only if :meth:`Process.name` was previously called.

  See also :ref:`faq_no_such_process` FAQ.

.. exception:: ZombieProcess(pid, name=None, ppid=None, msg=None)

  This may be raised by :class:`Process` class methods when querying a
  :term:`zombie process` on UNIX (Windows doesn't have zombie processes).
  *name* and *ppid* attributes are available if :meth:`Process.name` or
  :meth:`Process.ppid` methods were called before the process turned into a
  zombie.

  See also :ref:`faq_zombie_process` FAQ.

  .. note::

    this is a subclass of :exc:`NoSuchProcess` so if you're not interested
    in retrieving zombies (e.g. when using :func:`process_iter`) you can
    ignore this exception and just catch :exc:`NoSuchProcess`.

  .. versionadded:: 3.0.0

.. exception:: AccessDenied(pid=None, name=None, msg=None)

  Raised by :class:`Process` class methods when permission to perform an
  action is denied due to insufficient privileges.
  *name* attribute is available if :meth:`Process.name` was previously called.

  See also :ref:`faq_access_denied` FAQ.

.. exception:: TimeoutExpired(seconds, pid=None, name=None, msg=None)

  Raised by :meth:`Process.wait` method if timeout expires and the process is
  still alive.
  *name* attribute is available if :meth:`Process.name` was previously called.

Process class
^^^^^^^^^^^^^

.. class:: Process(pid=None)

  Represents an OS process with the given *pid*.
  If *pid* is omitted current process *pid* (:func:`os.getpid`) is used.
  Raise :exc:`NoSuchProcess` if *pid* does not exist.
  On Linux *pid* can also refer to a thread ID (the *id* field returned by
  :meth:`threads` method).
  When calling methods of this class, always be prepared to catch
  :exc:`NoSuchProcess` and :exc:`AccessDenied` exceptions.
  :func:`hash` builtin can be used against instances of this class in order to
  identify a process univocally over time (the hash is determined by mixing
  process PID + creation time). As such it can also be used with :class:`set`.

  .. note::

    In order to efficiently fetch more than one information about the process
    at the same time, make sure to use either :meth:`oneshot` context manager
    or :meth:`as_dict` utility method.

  .. note::

    the way this class is bound to a process is via its **PID**.
    That means that if the process terminates and the OS reuses its PID you may
    inadvertently end up interacting with another process. To prevent this
    problem you can use :meth:`is_running` first.
    Some methods (e.g. setters and signal-related methods) perform an
    additional check based on PID + creation time and will raise
    :exc:`NoSuchProcess` if the PID has been reused. See :ref:`faq_pid_reuse`
    FAQ for details.

  .. method:: oneshot()

    Utility context manager which considerably speeds up the retrieval of
    multiple process information at the same time.
    Internally different process info (e.g. :meth:`name`, :meth:`ppid`,
    :meth:`uids`, :meth:`create_time`, ...) may be fetched by using the same
    routine, but only one value is returned and the others are discarded.
    When using this context manager the internal routine is executed once (in
    the example below on :meth:`name`) the value of interest is returned and
    the others are cached.
    The subsequent calls sharing the same internal routine will return the
    cached value.
    The cache is cleared when exiting the context manager block.
    The advice is to use this every time you retrieve more than one information
    about the process. If you're lucky, you'll get a hell of a speedup.

    .. code-block:: pycon

       >>> import psutil
       >>> p = psutil.Process()
       >>> with p.oneshot():
       ...     p.name()  # execute internal routine once collecting multiple info
       ...     p.cpu_times()  # return cached value
       ...     p.cpu_percent()  # return cached value
       ...     p.create_time()  # return cached value
       ...     p.ppid()  # return cached value
       ...     p.status()  # return cached value
       ...
       >>>

    Here's a list of methods which can take advantage of the speedup depending
    on what platform you're on.
    In the table below horizontal empty rows indicate what process methods can
    be efficiently grouped together internally.
    The last column (speedup) shows an approximation of the speedup you can get
    if you call all the methods together (best case scenario).

    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | Linux                        | Windows                       | macOS                        | BSD                          | SunOS                    | AIX                      |
    +==============================+===============================+==============================+==============================+==========================+==========================+
    | :meth:`cpu_num`              | :meth:`~Process.cpu_percent`  | :meth:`~Process.cpu_percent` | :meth:`cpu_num`              | :meth:`name`             | :meth:`name`             |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`~Process.cpu_percent` | :meth:`cpu_times`             | :meth:`cpu_times`            | :meth:`~Process.cpu_percent` | :meth:`cmdline`          | :meth:`cmdline`          |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`cpu_times`            | :meth:`io_counters`           | :meth:`memory_info`          | :meth:`cpu_times`            | :meth:`create_time`      | :meth:`create_time`      |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`create_time`          | :meth:`memory_info`           | :meth:`memory_percent`       | :meth:`create_time`          |                          |                          |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`name`                 | :meth:`memory_info_ex`        | :meth:`num_ctx_switches`     | :meth:`gids`                 | :meth:`memory_info`      | :meth:`memory_info`      |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`ppid`                 | :meth:`num_ctx_switches`      | :meth:`num_threads`          | :meth:`io_counters`          | :meth:`memory_percent`   | :meth:`memory_percent`   |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`status`               | :meth:`num_handles`           |                              | :meth:`name`                 | :meth:`num_threads`      | :meth:`num_threads`      |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`terminal`             | :meth:`num_threads`           | :meth:`create_time`          | :meth:`memory_info`          | :meth:`ppid`             | :meth:`ppid`             |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    |                              |                               | :meth:`gids`                 | :meth:`memory_percent`       | :meth:`status`           | :meth:`status`           |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`gids`                 | :meth:`exe`                   | :meth:`name`                 | :meth:`num_ctx_switches`     | :meth:`terminal`         | :meth:`terminal`         |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`memory_info_ex`       | :meth:`name`                  | :meth:`ppid`                 | :meth:`ppid`                 |                          |                          |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`num_ctx_switches`     |                               | :meth:`status`               | :meth:`status`               | :meth:`gids`             | :meth:`gids`             |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`num_threads`          |                               | :meth:`terminal`             | :meth:`terminal`             | :meth:`uids`             | :meth:`uids`             |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`uids`                 |                               | :meth:`terminal`             | :meth:`terminal`             | :meth:`uids`             | :meth:`uids`             |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`username`             |                               | :meth:`uids`                 | :meth:`uids`                 | :meth:`username`         | :meth:`username`         |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    |                              |                               | :meth:`username`             | :meth:`username`             |                          |                          |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`memory_footprint`     |                               |                              |                              |                          |                          |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | :meth:`memory_maps`          |                               |                              |                              |                          |                          |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+
    | *speedup: +2.6x*             | *speedup: +1.8x / +6.5x*      | *speedup: +1.9x*             | *speedup: +2.0x*             | *speedup: +1.3x*         | *speedup: +1.3x*         |
    +------------------------------+-------------------------------+------------------------------+------------------------------+--------------------------+--------------------------+

    .. versionadded:: 5.0.0

  .. attribute:: pid

     The process PID. This is the only (read-only) attribute of the class.

  .. method:: ppid()

 
Download .txt
gitextract_40bz1e68/

├── .clang-format
├── .dprint.jsonc
├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug.md
│   │   ├── config.yml
│   │   └── enhancement.md
│   ├── PULL_REQUEST_TEMPLATE.md
│   ├── no-response.yml
│   ├── placeholder
│   └── workflows/
│       ├── bsd.yml
│       ├── build.yml
│       ├── changelog_bot.py
│       ├── changelog_bot.yml
│       ├── issues.py
│       ├── issues.yml
│       └── sunos.yml
├── .gitignore
├── CONTRIBUTING.md
├── HISTORY.rst
├── INSTALL.rst
├── LICENSE
├── MANIFEST.in
├── Makefile
├── README.rst
├── SECURITY.md
├── _bootstrap.py
├── docs/
│   ├── .readthedocs.yaml
│   ├── DEVNOTES
│   ├── Makefile
│   ├── README
│   ├── _ext/
│   │   ├── add_home_link.py
│   │   ├── availability.py
│   │   ├── changelog_anchors.py
│   │   └── check_python_syntax.py
│   ├── _links.rst
│   ├── _static/
│   │   ├── copybutton.js
│   │   ├── css/
│   │   │   └── custom.css
│   │   └── sidebar.js
│   ├── _templates/
│   │   └── layout.html
│   ├── adoption.rst
│   ├── alternatives.rst
│   ├── api.rst
│   ├── changelog.rst
│   ├── conf.py
│   ├── credits.rst
│   ├── devguide.rst
│   ├── faq.rst
│   ├── glossary.rst
│   ├── index.rst
│   ├── install.rst
│   ├── migration.rst
│   ├── platform.rst
│   ├── recipes.rst
│   ├── requirements.txt
│   ├── shell_equivalents.rst
│   └── timeline.rst
├── psutil/
│   ├── __init__.py
│   ├── _common.py
│   ├── _enums.py
│   ├── _ntuples.py
│   ├── _psaix.py
│   ├── _psbsd.py
│   ├── _pslinux.py
│   ├── _psosx.py
│   ├── _psposix.py
│   ├── _pssunos.py
│   ├── _psutil_aix.c
│   ├── _psutil_bsd.c
│   ├── _psutil_linux.c
│   ├── _psutil_osx.c
│   ├── _psutil_sunos.c
│   ├── _psutil_windows.c
│   ├── _pswindows.py
│   └── arch/
│       ├── aix/
│       │   ├── common.c
│       │   ├── common.h
│       │   ├── ifaddrs.c
│       │   ├── ifaddrs.h
│       │   ├── net_connections.c
│       │   ├── net_connections.h
│       │   └── net_kernel_structs.h
│       ├── all/
│       │   ├── errors.c
│       │   ├── init.c
│       │   ├── init.h
│       │   ├── pids.c
│       │   ├── str.c
│       │   └── utils.c
│       ├── bsd/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── heap.c
│       │   ├── init.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── net.c
│       │   ├── proc.c
│       │   ├── proc_utils.c
│       │   └── sys.c
│       ├── freebsd/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   ├── proc_socks.c
│       │   ├── sensors.c
│       │   └── sys_socks.c
│       ├── linux/
│       │   ├── disk.c
│       │   ├── heap.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── net.c
│       │   └── proc.c
│       ├── netbsd/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   └── socks.c
│       ├── openbsd/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   ├── socks.c
│       │   └── users.c
│       ├── osx/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── heap.c
│       │   ├── init.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── net.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   ├── proc_utils.c
│       │   ├── sensors.c
│       │   └── sys.c
│       ├── posix/
│       │   ├── init.c
│       │   ├── init.h
│       │   ├── net.c
│       │   ├── pids.c
│       │   ├── proc.c
│       │   ├── sysctl.c
│       │   └── users.c
│       ├── sunos/
│       │   ├── cpu.c
│       │   ├── disk.c
│       │   ├── environ.c
│       │   ├── init.h
│       │   ├── mem.c
│       │   ├── net.c
│       │   ├── proc.c
│       │   └── sys.c
│       └── windows/
│           ├── cpu.c
│           ├── disk.c
│           ├── heap.c
│           ├── init.c
│           ├── init.h
│           ├── mem.c
│           ├── net.c
│           ├── ntextapi.h
│           ├── pids.c
│           ├── proc.c
│           ├── proc_handles.c
│           ├── proc_info.c
│           ├── proc_utils.c
│           ├── security.c
│           ├── sensors.c
│           ├── services.c
│           ├── socks.c
│           ├── sys.c
│           └── wmi.c
├── pyproject.toml
├── scripts/
│   ├── battery.py
│   ├── cpu_distribution.py
│   ├── disk_usage.py
│   ├── fans.py
│   ├── free.py
│   ├── ifconfig.py
│   ├── internal/
│   │   ├── README
│   │   ├── bench_oneshot.py
│   │   ├── bench_oneshot_2.py
│   │   ├── convert_readme.py
│   │   ├── download_wheels.py
│   │   ├── find_adopters.py
│   │   ├── find_broken_links.py
│   │   ├── generate_manifest.py
│   │   ├── git_pre_commit.py
│   │   ├── install-sysdeps.sh
│   │   ├── install_pip.py
│   │   ├── print_access_denied.py
│   │   ├── print_announce.py
│   │   ├── print_api_speed.py
│   │   ├── print_dist.py
│   │   ├── print_downloads.py
│   │   ├── print_hashes.py
│   │   ├── print_sysinfo.py
│   │   ├── purge_installation.py
│   │   └── rst_check_dead_refs.py
│   ├── iotop.py
│   ├── killall.py
│   ├── meminfo.py
│   ├── netstat.py
│   ├── nettop.py
│   ├── pidof.py
│   ├── pmap.py
│   ├── procinfo.py
│   ├── procsmem.py
│   ├── ps.py
│   ├── pstree.py
│   ├── sensors.py
│   ├── temperatures.py
│   ├── top.py
│   ├── who.py
│   └── winservices.py
├── setup.py
└── tests/
    ├── README.md
    ├── __init__.py
    ├── test_aix.py
    ├── test_bsd.py
    ├── test_connections.py
    ├── test_contracts.py
    ├── test_heap.py
    ├── test_linux.py
    ├── test_memleaks.py
    ├── test_misc.py
    ├── test_osx.py
    ├── test_posix.py
    ├── test_process.py
    ├── test_process_all.py
    ├── test_scripts.py
    ├── test_sudo.py
    ├── test_sunos.py
    ├── test_system.py
    ├── test_testutils.py
    ├── test_type_hints.py
    ├── test_unicode.py
    └── test_windows.py
Download .txt
SYMBOL INDEX (2269 symbols across 177 files)

FILE: .github/workflows/changelog_bot.py
  function gh_request (line 222) | def gh_request(path, accept="application/vnd.github+json"):
  function fetch_pr_metadata (line 236) | def fetch_pr_metadata():
  function fetch_pr_diff (line 251) | def fetch_pr_diff():
  function ask_claude (line 258) | def ask_claude(pr, diff):
  function insert_changelog_entry (line 280) | def insert_changelog_entry(section, entry):
  function update_credits (line 366) | def update_credits(credits_entry, author, author_name):
  function post_comment (line 479) | def post_comment(body):
  function parse_cli (line 496) | def parse_cli():
  function main (line 510) | def main():

FILE: .github/workflows/issues.py
  function is_pr (line 139) | def is_pr(issue):
  function has_label (line 143) | def has_label(issue, label):
  function get_repo (line 148) | def get_repo():
  function _get_event_data (line 158) | def _get_event_data():
  function is_event_new_issue (line 165) | def is_event_new_issue():
  function is_event_new_pr (line 173) | def is_event_new_pr():
  function get_issue (line 181) | def get_issue():
  function log (line 193) | def log(msg):
  function add_label (line 200) | def add_label(issue, label):
  function _guess_labels_from_text (line 221) | def _guess_labels_from_text(text):
  function add_labels_from_text (line 229) | def add_labels_from_text(issue, text):
  function add_labels_from_new_body (line 235) | def add_labels_from_new_body(issue, text):
  function on_new_issue (line 292) | def on_new_issue(issue):
  function on_new_pr (line 319) | def on_new_pr(issue):
  function main (line 327) | def main():

FILE: _bootstrap.py
  function load_module (line 17) | def load_module(path):
  function get_version (line 28) | def get_version():

FILE: docs/_ext/add_home_link.py
  function add_home_link (line 12) | def add_home_link(app: Sphinx, pagename, templatename, context, doctree):
  function setup (line 23) | def setup(app: Sphinx):

FILE: docs/_ext/availability.py
  class Availability (line 42) | class Availability(SphinxDirective):
    method run (line 48) | def run(self):
    method parse_platforms (line 64) | def parse_platforms(self):
  function setup (line 99) | def setup(app):

FILE: docs/_ext/changelog_anchors.py
  function add_version_anchors (line 19) | def add_version_anchors(app, doctree, docname):
  function setup (line 36) | def setup(app):

FILE: docs/_ext/check_python_syntax.py
  function check_python_blocks (line 15) | def check_python_blocks(app, doctree, docname):
  function setup (line 43) | def setup(app):

FILE: docs/_static/sidebar.js
  function sidebar_is_collapsed (line 45) | function sidebar_is_collapsed() {
  function toggle_sidebar (line 49) | function toggle_sidebar() {
  function collapse_sidebar (line 56) | function collapse_sidebar() {
  function expand_sidebar (line 71) | function expand_sidebar() {
  function add_sidebar_button (line 88) | function add_sidebar_button() {
  function set_position_from_cookie (line 141) | function set_position_from_cookie() {

FILE: psutil/__init__.py
  function _export_enum (line 186) | def _export_enum(cls):
  function _ppid_map (line 257) | def _ppid_map():
  function _pprint_secs (line 270) | def _pprint_secs(secs):
  function _check_conn_kind (line 278) | def _check_conn_kind(kind):
  class Process (line 291) | class Process:
    method __init__ (line 319) | def __init__(self, pid: int | None = None) -> None:
    method _init (line 322) | def _init(self, pid, _ignore_nsp=False):
    method _get_ident (line 369) | def _get_ident(self):
    method __str__ (line 404) | def __str__(self):
    method __eq__ (line 436) | def __eq__(self, other):
    method __ne__ (line 457) | def __ne__(self, other):
    method __hash__ (line 460) | def __hash__(self):
    method _raise_if_pid_reused (line 465) | def _raise_if_pid_reused(self):
    method pid (line 478) | def pid(self) -> int:
    method oneshot (line 485) | def oneshot(self) -> Generator[None, None, None]:
    method as_dict (line 551) | def as_dict(
    method parent (line 600) | def parent(self) -> Process | None:
    method parents (line 622) | def parents(self) -> list[Process]:
    method is_running (line 633) | def is_running(self) -> bool:
    method ppid (line 663) | def ppid(self) -> int:
    method name (line 681) | def name(self) -> str:
    method exe (line 712) | def exe(self) -> str:
    method cmdline (line 754) | def cmdline(self) -> list[str]:
    method status (line 758) | def status(self) -> ProcessStatus | str:
    method username (line 765) | def username(self) -> str:
    method create_time (line 783) | def create_time(self) -> float:
    method cwd (line 795) | def cwd(self) -> str:
    method nice (line 799) | def nice(self, value: int | None = None) -> int | None:
    method uids (line 810) | def uids(self) -> puids:
    method gids (line 816) | def gids(self) -> pgids:
    method terminal (line 822) | def terminal(self) -> str | None:
    method num_fds (line 828) | def num_fds(self) -> int:
    method io_counters (line 837) | def io_counters(self) -> pio:
    method ionice (line 849) | def ionice(
    method rlimit (line 875) | def rlimit(
    method cpu_affinity (line 896) | def cpu_affinity(
    method cpu_num (line 920) | def cpu_num(self) -> int:
    method environ (line 933) | def environ(self) -> dict[str, str]:
    method num_handles (line 941) | def num_handles(self) -> int:
    method num_ctx_switches (line 947) | def num_ctx_switches(self) -> pctxsw:
    method num_threads (line 953) | def num_threads(self) -> int:
    method threads (line 959) | def threads(self) -> list[pthread]:
    method children (line 967) | def children(self, recursive: bool = False) -> list[Process]:
    method cpu_percent (line 1041) | def cpu_percent(self, interval: float | None = None) -> float:
    method cpu_times (line 1135) | def cpu_times(self) -> pcputimes:
    method memory_info (line 1146) | def memory_info(self) -> pmem:
    method memory_info_ex (line 1157) | def memory_info_ex(self) -> pmem_ex:
    method memory_footprint (line 1172) | def memory_footprint(self) -> pfootprint:
    method memory_full_info (line 1188) | def memory_full_info(self) -> pfullmem:
    method memory_percent (line 1204) | def memory_percent(self, memtype: str = "rss") -> float:
    method memory_maps (line 1253) | def memory_maps(
    method page_faults (line 1280) | def page_faults(self) -> ppagefaults:
    method open_files (line 1298) | def open_files(self) -> list[popenfile]:
    method net_connections (line 1305) | def net_connections(self, kind: str = "inet") -> list[pconn]:
    method connections (line 1331) | def connections(self, kind="inet") -> list[pconn]:
    method _send_signal (line 1338) | def _send_signal(self, sig):
    method send_signal (line 1363) | def send_signal(self, sig: int) -> None:
    method suspend (line 1378) | def suspend(self) -> None:
    method resume (line 1389) | def resume(self) -> None:
    method terminate (line 1400) | def terminate(self) -> None:
    method kill (line 1411) | def kill(self) -> None:
    method wait (line 1421) | def wait(self, timeout: float | None = None) -> int | None:
  class Popen (line 1481) | class Popen(Process):
    method __init__ (line 1511) | def __init__(self, *args, **kwargs):
    method __dir__ (line 1518) | def __dir__(self):
    method __enter__ (line 1521) | def __enter__(self) -> Popen:
    method __exit__ (line 1526) | def __exit__(self, *args, **kwargs):
    method __getattribute__ (line 1542) | def __getattribute__(self, name):
    method wait (line 1552) | def wait(self, timeout: float | None = None) -> int | None:
  function pids (line 1565) | def pids() -> list[int]:
  function pid_exists (line 1573) | def pid_exists(pid: int) -> bool:
  function process_iter (line 1595) | def process_iter(
  function wait_procs (line 1655) | def wait_procs(
  function cpu_count (line 1756) | def cpu_count(logical: bool = True) -> int | None:
  function cpu_times (line 1779) | def cpu_times(percpu: bool = False) -> scputimes | list[scputimes]:
  function _cpu_tot_time (line 1822) | def _cpu_tot_time(times):
  function _cpu_busy_time (line 1839) | def _cpu_busy_time(times):
  function _cpu_times_deltas (line 1854) | def _cpu_times_deltas(t1, t2):
  function cpu_percent (line 1875) | def cpu_percent(
  function cpu_times_percent (line 1959) | def cpu_times_percent(
  function cpu_stats (line 2020) | def cpu_stats() -> scpustats:
  function cpu_freq (line 2027) | def cpu_freq(percpu: bool = False) -> scpufreq | list[scpufreq] | None:
  function getloadavg (line 2070) | def getloadavg() -> tuple[float, float, float]:
  function virtual_memory (line 2087) | def virtual_memory() -> svmem:
  function swap_memory (line 2146) | def swap_memory() -> sswap:
  function disk_usage (line 2167) | def disk_usage(path: str) -> sdiskusage:
  function disk_partitions (line 2175) | def disk_partitions(all: bool = False) -> list[sdiskpart]:
  function disk_io_counters (line 2187) | def disk_io_counters(
  function net_io_counters (line 2246) | def net_io_counters(
  function net_connections (line 2293) | def net_connections(kind: str = 'inet') -> list[sconn]:
  function net_if_addrs (line 2323) | def net_if_addrs() -> dict[str, list[snicaddr]]:
  function net_if_stats (line 2384) | def net_if_stats() -> dict[str, snicstats]:
  function sensors_temperatures (line 2407) | def sensors_temperatures(
  function sensors_fans (line 2447) | def sensors_fans() -> dict[str, list[sfan]]:
  function sensors_battery (line 2460) | def sensors_battery() -> sbattery | None:
  function boot_time (line 2480) | def boot_time() -> float:
  function users (line 2490) | def users() -> list[suser]:
  function win_service_iter (line 2510) | def win_service_iter() -> Iterator[WindowsService]:
  function win_service_get (line 2516) | def win_service_get(name) -> WindowsService:
  function heap_info (line 2531) | def heap_info() -> pheap:
  function heap_trim (line 2547) | def heap_trim() -> None:
  function _set_debug (line 2572) | def _set_debug(value):

FILE: psutil/_common.py
  class Error (line 107) | class Error(Exception):
    method _infodict (line 114) | def _infodict(self, attrs):
    method __str__ (line 122) | def __str__(self):
    method __repr__ (line 133) | def __repr__(self):
  class NoSuchProcess (line 140) | class NoSuchProcess(Error):
    method __init__ (line 147) | def __init__(self, pid, name=None, msg=None):
    method __reduce__ (line 153) | def __reduce__(self):
  class ZombieProcess (line 157) | class ZombieProcess(NoSuchProcess):
    method __init__ (line 167) | def __init__(self, pid, name=None, ppid=None, msg=None):
    method __reduce__ (line 172) | def __reduce__(self):
  class AccessDenied (line 176) | class AccessDenied(Error):
    method __init__ (line 181) | def __init__(self, pid=None, name=None, msg=None):
    method __reduce__ (line 187) | def __reduce__(self):
  class TimeoutExpired (line 191) | class TimeoutExpired(Error):
    method __init__ (line 198) | def __init__(self, seconds, pid=None, name=None):
    method __reduce__ (line 205) | def __reduce__(self):
  function usage_percent (line 214) | def usage_percent(used, total, round_=None):
  function memoize_when_activated (line 226) | def memoize_when_activated(fun):
  function isfile_strict (line 297) | def isfile_strict(path):
  function path_exists_strict (line 312) | def path_exists_strict(path):
  function supports_ipv6 (line 327) | def supports_ipv6():
  function parse_environ_block (line 339) | def parse_environ_block(data):
  function sockfam_to_enum (line 367) | def sockfam_to_enum(num):
  function socktype_to_enum (line 377) | def socktype_to_enum(num):
  function conn_to_ntuple (line 387) | def conn_to_ntuple(fd, fam, type_, laddr, raddr, status, status_map, pid...
  function broadcast_addr (line 409) | def broadcast_addr(addr):
  function deprecated_method (line 431) | def deprecated_method(replacement):
  class deprecated_property (line 454) | class deprecated_property:
    method __init__ (line 462) | def __init__(self, replacement):
    method __set_name__ (line 466) | def __set_name__(self, owner, name):
    method __get__ (line 472) | def __get__(self, obj, objtype=None):
  class _WrapNumbers (line 479) | class _WrapNumbers:
    method __init__ (line 484) | def __init__(self):
    method _add_dict (line 490) | def _add_dict(self, input_dict, name):
    method _remove_dead_reminders (line 498) | def _remove_dead_reminders(self, input_dict, name):
    method run (line 509) | def run(self, input_dict, name):
    method cache_clear (line 548) | def cache_clear(self, name=None):
    method cache_info (line 560) | def cache_info(self):
  function wrap_numbers (line 566) | def wrap_numbers(input_dict, name):
  function open_binary (line 593) | def open_binary(fname):
  function open_text (line 597) | def open_text(fname):
  function cat (line 623) | def cat(fname, fallback=_DEFAULT, _open=open_text):
  function bcat (line 640) | def bcat(fname, fallback=_DEFAULT):
  function bytes2human (line 645) | def bytes2human(n, format="%(value).1f%(symbol)s"):
  function get_procfs_path (line 664) | def get_procfs_path():
  function decode (line 669) | def decode(s):
  function term_supports_colors (line 679) | def term_supports_colors(force_color=False):
  function hilite (line 693) | def hilite(s, color=None, bold=False, force_color=False):
  function print_color (line 721) | def print_color(
  function debug (line 730) | def debug(msg):

FILE: psutil/_enums.py
  class StrEnum (line 43) | class StrEnum(str, enum.Enum):
    method __new__ (line 44) | def __new__(cls, *values):
    method _generate_next_value_ (line 53) | def _generate_next_value_(name, _start, _count, _last_values):
  class ProcessStatus (line 58) | class ProcessStatus(StrEnum):
  class ConnectionStatus (line 76) | class ConnectionStatus(StrEnum):
  class NicDuplex (line 97) | class NicDuplex(enum.IntEnum):
  class BatteryTime (line 104) | class BatteryTime(enum.IntEnum):
  class ProcessIOPriority (line 112) | class ProcessIOPriority(enum.IntEnum):
  class ProcessIOPriority (line 123) | class ProcessIOPriority(enum.IntEnum):
  class ProcessPriority (line 130) | class ProcessPriority(enum.IntEnum):

FILE: psutil/_ntuples.py
  class sswap (line 36) | class sswap(NamedTuple):
  class sdiskusage (line 46) | class sdiskusage(NamedTuple):
  class sdiskio (line 54) | class sdiskio(NamedTuple):
  class sdiskpart (line 71) | class sdiskpart(NamedTuple):
  class snetio (line 79) | class snetio(NamedTuple):
  class suser (line 91) | class suser(NamedTuple):
  class addr (line 100) | class addr(NamedTuple):
  class sconn (line 106) | class sconn(NamedTuple):
  class snicaddr (line 117) | class snicaddr(NamedTuple):
  class snicstats (line 126) | class snicstats(NamedTuple):
  class scputimes (line 135) | class scputimes(NamedTuple):
    method interrupt (line 157) | def interrupt(self):
  class scpustats (line 164) | class scpustats(NamedTuple):
  class scpufreq (line 172) | class scpufreq(NamedTuple):
  class shwtemp (line 179) | class shwtemp(NamedTuple):
  class sbattery (line 187) | class sbattery(NamedTuple):
  class sfan (line 194) | class sfan(NamedTuple):
  class pheap (line 202) | class pheap(NamedTuple):
  class svmem (line 210) | class svmem(NamedTuple):
  class pcputimes (line 245) | class pcputimes(NamedTuple):
  class popenfile (line 255) | class popenfile(NamedTuple):
  class pthread (line 265) | class pthread(NamedTuple):
  class puids (line 272) | class puids(NamedTuple):
  class pgids (line 279) | class pgids(NamedTuple):
  class pio (line 286) | class pio(NamedTuple):
  class pionice (line 300) | class pionice(NamedTuple):
  class pctxsw (line 306) | class pctxsw(NamedTuple):
  class ppagefaults (line 312) | class ppagefaults(NamedTuple):
  class pfootprint (line 320) | class pfootprint(NamedTuple):
  class pconn (line 328) | class pconn(NamedTuple):
  class pmmap_grouped (line 338) | class pmmap_grouped(NamedTuple):
  class pmmap_ext (line 361) | class pmmap_ext(NamedTuple):
  class pmem (line 392) | class pmem(NamedTuple):
    method lib (line 400) | def lib(self):
    method dirty (line 407) | def dirty(self):
    method __new__ (line 437) | def __new__(cls, rss, vms, peak_rss, peak_vms, _deprecated=None):
    method __getattr__ (line 442) | def __getattr__(self, name):
  class pmem (line 434) | class pmem(  # noqa: SLOT002
    method lib (line 400) | def lib(self):
    method dirty (line 407) | def dirty(self):
    method __new__ (line 437) | def __new__(cls, rss, vms, peak_rss, peak_vms, _deprecated=None):
    method __getattr__ (line 442) | def __getattr__(self, name):
  class pmem (line 481) | class pmem(NamedTuple):
    method lib (line 400) | def lib(self):
    method dirty (line 407) | def dirty(self):
    method __new__ (line 437) | def __new__(cls, rss, vms, peak_rss, peak_vms, _deprecated=None):
    method __getattr__ (line 442) | def __getattr__(self, name):
  class pmem_ex (line 486) | class pmem_ex(NamedTuple):
  class pmem (line 502) | class pmem(NamedTuple):
    method lib (line 400) | def lib(self):
    method dirty (line 407) | def dirty(self):
    method __new__ (line 437) | def __new__(cls, rss, vms, peak_rss, peak_vms, _deprecated=None):
    method __getattr__ (line 442) | def __getattr__(self, name):
  class pmem (line 519) | class pmem(NamedTuple):
    method lib (line 400) | def lib(self):
    method dirty (line 407) | def dirty(self):
    method __new__ (line 437) | def __new__(cls, rss, vms, peak_rss, peak_vms, _deprecated=None):
    method __getattr__ (line 442) | def __getattr__(self, name):

FILE: psutil/_psaix.py
  function virtual_memory (line 86) | def virtual_memory():
  function swap_memory (line 92) | def swap_memory():
  function cpu_times (line 105) | def cpu_times():
  function per_cpu_times (line 111) | def per_cpu_times():
  function cpu_count_logical (line 117) | def cpu_count_logical():
  function cpu_count_cores (line 126) | def cpu_count_cores():
  function cpu_stats (line 138) | def cpu_stats():
  function disk_partitions (line 153) | def disk_partitions(all=False):
  function net_connections (line 185) | def net_connections(kind, _pid=-1):
  function net_if_stats (line 212) | def net_if_stats():
  function boot_time (line 258) | def boot_time():
  function users (line 263) | def users():
  function pids (line 287) | def pids():
  function pid_exists (line 292) | def pid_exists(pid):
  function wrap_exceptions (line 297) | def wrap_exceptions(fun):
  class Process (line 320) | class Process:
    method __init__ (line 325) | def __init__(self, pid):
    method oneshot_enter (line 331) | def oneshot_enter(self):
    method oneshot_exit (line 335) | def oneshot_exit(self):
    method _proc_oneshot (line 341) | def _proc_oneshot(self):
    method _proc_cred (line 346) | def _proc_cred(self):
    method name (line 350) | def name(self):
    method exe (line 357) | def exe(self):
    method cmdline (line 387) | def cmdline(self):
    method environ (line 391) | def environ(self):
    method create_time (line 395) | def create_time(self):
    method num_threads (line 399) | def num_threads(self):
    method threads (line 405) | def threads(self):
    method net_connections (line 422) | def net_connections(self, kind='inet'):
    method nice_get (line 435) | def nice_get(self):
    method nice_set (line 439) | def nice_set(self, value):
    method ppid (line 443) | def ppid(self):
    method uids (line 448) | def uids(self):
    method gids (line 453) | def gids(self):
    method cpu_times (line 458) | def cpu_times(self):
    method terminal (line 463) | def terminal(self):
    method cwd (line 474) | def cwd(self):
    method memory_info (line 484) | def memory_info(self):
    method status (line 491) | def status(self):
    method open_files (line 496) | def open_files(self):
    method num_fds (line 522) | def num_fds(self):
    method num_ctx_switches (line 528) | def num_ctx_switches(self):
    method wait (line 532) | def wait(self, timeout=None):
    method io_counters (line 538) | def io_counters(self):

FILE: psutil/_psbsd.py
  function virtual_memory (line 109) | def virtual_memory():
  function swap_memory (line 114) | def swap_memory():
  function cpu_times (line 133) | def cpu_times():
  function per_cpu_times (line 139) | def per_cpu_times():
  function cpu_count_logical (line 149) | def cpu_count_logical():
  function cpu_count_cores (line 156) | def cpu_count_cores():
  function cpu_count_cores (line 162) | def cpu_count_cores():
  function cpu_stats (line 189) | def cpu_stats():
  function cpu_freq (line 223) | def cpu_freq():
  function cpu_freq (line 249) | def cpu_freq():
  function disk_partitions (line 259) | def disk_partitions(all=False):
  function net_if_stats (line 286) | def net_if_stats():
  function net_connections (line 307) | def net_connections(kind):
  function sensors_battery (line 334) | def sensors_battery():
  function sensors_temperatures (line 350) | def sensors_temperatures():
  function boot_time (line 372) | def boot_time():
  function adjust_proc_create_time (line 386) | def adjust_proc_create_time(ctime):
  function users (line 401) | def users():
  function _pid_0_exists (line 420) | def _pid_0_exists():
  function pids (line 431) | def pids():
  function pid_exists (line 443) | def pid_exists(pid):
  function pid_exists (line 454) | def pid_exists(pid):
  function wrap_exceptions (line 468) | def wrap_exceptions(fun):
  function wrap_exceptions_procfs (line 495) | def wrap_exceptions_procfs(inst):
  class Process (line 512) | class Process:
    method __init__ (line 517) | def __init__(self, pid):
    method _assert_alive (line 522) | def _assert_alive(self):
    method oneshot (line 530) | def oneshot(self):
    method oneshot_enter (line 534) | def oneshot_enter(self):
    method oneshot_exit (line 537) | def oneshot_exit(self):
    method name (line 541) | def name(self):
    method exe (line 546) | def exe(self):
    method cmdline (line 571) | def cmdline(self):
    method environ (line 598) | def environ(self):
    method terminal (line 602) | def terminal(self):
    method ppid (line 611) | def ppid(self):
    method uids (line 616) | def uids(self):
    method gids (line 621) | def gids(self):
    method cpu_times (line 626) | def cpu_times(self):
    method cpu_num (line 635) | def cpu_num(self):
    method memory_info (line 639) | def memory_info(self):
    method create_time (line 651) | def create_time(self, monotonic=False):
    method num_threads (line 659) | def num_threads(self):
    method num_ctx_switches (line 667) | def num_ctx_switches(self):
    method page_faults (line 672) | def page_faults(self):
    method threads (line 677) | def threads(self):
    method net_connections (line 689) | def net_connections(self, kind='inet'):
    method wait (line 714) | def wait(self, timeout=None):
    method nice_get (line 718) | def nice_get(self):
    method nice_set (line 722) | def nice_set(self, value):
    method status (line 726) | def status(self):
    method io_counters (line 732) | def io_counters(self):
    method cwd (line 737) | def cwd(self):
    method open_files (line 753) | def open_files(self):
    method num_fds (line 759) | def num_fds(self):
    method cpu_affinity_get (line 771) | def cpu_affinity_get(self):
    method cpu_affinity_set (line 775) | def cpu_affinity_set(self, cpus):
    method memory_maps (line 802) | def memory_maps(self):
    method rlimit (line 806) | def rlimit(self, resource, limits=None):

FILE: psutil/_pslinux.py
  function readlink (line 128) | def readlink(path):
  function file_flags_to_mode (line 148) | def file_flags_to_mode(flags):
  function is_storage_device (line 161) | def is_storage_device(name):
  function calculate_avail_vmem (line 184) | def calculate_avail_vmem(mems):
  function virtual_memory (line 246) | def virtual_memory():
  function swap_memory (line 373) | def swap_memory():
  function cpu_times (line 439) | def cpu_times():
  function per_cpu_times (line 469) | def per_cpu_times():
  function cpu_count_logical (line 489) | def cpu_count_logical():
  function cpu_count_cores (line 518) | def cpu_count_cores():
  function cpu_stats (line 560) | def cpu_stats():
  function _cpu_get_cpuinfo_freq (line 583) | def _cpu_get_cpuinfo_freq():
  function cpu_freq (line 597) | def cpu_freq():
  function cpu_freq (line 636) | def cpu_freq():
  class _Ipv6UnsupportedError (line 651) | class _Ipv6UnsupportedError(Exception):
  class NetConnections (line 655) | class NetConnections:
    method __init__ (line 667) | def __init__(self):
    method get_proc_inodes (line 690) | def get_proc_inodes(self, pid):
    method get_all_inodes (line 716) | def get_all_inodes(self):
    method decode_address (line 733) | def decode_address(addr, family):
    method process_inet (line 784) | def process_inet(file, family, type_, inodes, filter_pid=None):
    method process_unix (line 827) | def process_unix(file, family, inodes, filter_pid=None):
    method retrieve (line 862) | def retrieve(self, kind, pid=None):
  function net_connections (line 894) | def net_connections(kind='inet'):
  function net_io_counters (line 899) | def net_io_counters():
  function net_if_stats (line 946) | def net_if_stats():
  function disk_io_counters (line 982) | def disk_io_counters(perdisk=False):
  class RootFsDeviceFinder (line 1087) | class RootFsDeviceFinder:
    method __init__ (line 1097) | def __init__(self):
    method ask_proc_partitions (line 1102) | def ask_proc_partitions(self):
    method ask_sys_dev_block (line 1115) | def ask_sys_dev_block(self):
    method ask_sys_class_block (line 1124) | def ask_sys_class_block(self):
    method find (line 1139) | def find(self):
  function disk_partitions (line 1162) | def disk_partitions(all=False):
  function sensors_temperatures (line 1206) | def sensors_temperatures():
  function sensors_fans (line 1324) | def sensors_fans():
  function sensors_battery (line 1355) | def sensors_battery():
  function users (line 1447) | def users():
  function boot_time (line 1458) | def boot_time():
  function pids (line 1474) | def pids():
  function pid_exists (line 1480) | def pid_exists(pid):
  function ppid_map (line 1513) | def ppid_map():
  function wrap_exceptions (line 1535) | def wrap_exceptions(fun):
  class Process (line 1562) | class Process:
    method __init__ (line 1574) | def __init__(self, pid):
    method _is_zombie (line 1581) | def _is_zombie(self):
    method _raise_if_zombie (line 1597) | def _raise_if_zombie(self):
    method _raise_if_not_alive (line 1601) | def _raise_if_not_alive(self):
    method _readlink (line 1607) | def _readlink(self, path, fallback=UNSET):
    method _parse_stat_file (line 1625) | def _parse_stat_file(self):
    method _read_status_file (line 1666) | def _read_status_file(self):
    method _read_smaps_file (line 1676) | def _read_smaps_file(self):
    method oneshot_enter (line 1680) | def oneshot_enter(self):
    method oneshot_exit (line 1685) | def oneshot_exit(self):
    method name (line 1691) | def name(self):
    method exe (line 1696) | def exe(self):
    method cmdline (line 1702) | def cmdline(self):
    method environ (line 1728) | def environ(self):
    method terminal (line 1734) | def terminal(self):
    method io_counters (line 1746) | def io_counters(self):
    method cpu_times (line 1781) | def cpu_times(self):
    method cpu_num (line 1793) | def cpu_num(self):
    method wait (line 1798) | def wait(self, timeout=None):
    method create_time (line 1802) | def create_time(self, monotonic=False):
    method memory_info (line 1819) | def memory_info(self):
    method memory_info_ex (line 1838) | def memory_info_ex(
    method _parse_smaps_rollup (line 1870) | def _parse_smaps_rollup(self):
    method _parse_smaps (line 1894) | def _parse_smaps(
    method memory_footprint (line 1923) | def memory_footprint(self):
    method memory_maps (line 1938) | def memory_maps(self):
    method page_faults (line 2010) | def page_faults(self):
    method cwd (line 2015) | def cwd(self):
    method num_ctx_switches (line 2021) | def num_ctx_switches(
    method num_threads (line 2037) | def num_threads(self, _num_threads_re=re.compile(br'Threads:\t(\d+)')):
    method threads (line 2043) | def threads(self):
    method nice_get (line 2070) | def nice_get(self):
    method nice_set (line 2079) | def nice_set(self, value):
    method cpu_affinity_get (line 2086) | def cpu_affinity_get(self):
    method _get_eligible_cpus (line 2089) | def _get_eligible_cpus(
    method cpu_affinity_set (line 2101) | def cpu_affinity_set(self, cpus):
    method ionice_get (line 2127) | def ionice_get(self):
    method ionice_set (line 2133) | def ionice_set(self, ioclass, value):
    method rlimit (line 2150) | def rlimit(self, resource_, limits=None):
    method status (line 2178) | def status(self):
    method open_files (line 2185) | def open_files(self):
    method net_connections (line 2233) | def net_connections(self, kind='inet'):
    method num_fds (line 2239) | def num_fds(self):
    method ppid (line 2243) | def ppid(self):
    method uids (line 2247) | def uids(self, _uids_re=re.compile(br'Uid:\t(\d+)\t(\d+)\t(\d+)')):
    method gids (line 2253) | def gids(self, _gids_re=re.compile(br'Gid:\t(\d+)\t(\d+)\t(\d+)')):

FILE: psutil/_psosx.py
  function virtual_memory (line 69) | def virtual_memory():
  function swap_memory (line 78) | def swap_memory():
  function cpu_times (line 95) | def cpu_times():
  function per_cpu_times (line 101) | def per_cpu_times():
  function cpu_count_logical (line 111) | def cpu_count_logical():
  function cpu_count_cores (line 116) | def cpu_count_cores():
  function cpu_stats (line 121) | def cpu_stats():
  function cpu_freq (line 130) | def cpu_freq():
  function disk_partitions (line 149) | def disk_partitions(all=False):
  function sensors_battery (line 170) | def sensors_battery():
  function net_connections (line 196) | def net_connections(kind='inet'):
  function net_if_stats (line 214) | def net_if_stats():
  function boot_time (line 240) | def boot_time():
  function adjust_proc_create_time (line 253) | def adjust_proc_create_time(ctime):
  function users (line 268) | def users():
  function pids (line 288) | def pids():
  function wrap_exceptions (line 307) | def wrap_exceptions(fun):
  class Process (line 329) | class Process:
    method __init__ (line 334) | def __init__(self, pid):
    method _oneshot_kinfo (line 341) | def _oneshot_kinfo(self):
    method _oneshot_pidtaskinfo (line 347) | def _oneshot_pidtaskinfo(self):
    method oneshot_enter (line 351) | def oneshot_enter(self):
    method oneshot_exit (line 355) | def oneshot_exit(self):
    method name (line 360) | def name(self):
    method exe (line 365) | def exe(self):
    method cmdline (line 369) | def cmdline(self):
    method environ (line 373) | def environ(self):
    method ppid (line 377) | def ppid(self):
    method cwd (line 382) | def cwd(self):
    method uids (line 386) | def uids(self):
    method gids (line 391) | def gids(self):
    method terminal (line 396) | def terminal(self):
    method memory_info (line 405) | def memory_info(self):
    method memory_info_ex (line 410) | def memory_info_ex(self):
    method memory_footprint (line 414) | def memory_footprint(self):
    method page_faults (line 419) | def page_faults(self):
    method cpu_times (line 424) | def cpu_times(self):
    method create_time (line 430) | def create_time(self, monotonic=False):
    method num_ctx_switches (line 437) | def num_ctx_switches(self):
    method num_threads (line 445) | def num_threads(self):
    method open_files (line 449) | def open_files(self):
    method net_connections (line 461) | def net_connections(self, kind='inet'):
    method num_fds (line 474) | def num_fds(self):
    method wait (line 480) | def wait(self, timeout=None):
    method nice_get (line 484) | def nice_get(self):
    method nice_set (line 488) | def nice_set(self, value):
    method status (line 492) | def status(self):
    method threads (line 498) | def threads(self):

FILE: psutil/_psposix.py
  function pid_exists (line 29) | def pid_exists(pid):
  function negsig_to_enum (line 56) | def negsig_to_enum(num):
  function convert_exit_code (line 64) | def convert_exit_code(status):
  function wait_pid_posix (line 95) | def wait_pid_posix(
  function _waitpid (line 163) | def _waitpid(pid, timeout):
  function wait_pid_pidfd_open (line 177) | def wait_pid_pidfd_open(pid, timeout=None):
  function wait_pid_kqueue (line 206) | def wait_pid_kqueue(pid, timeout=None):
  function can_use_pidfd_open (line 238) | def can_use_pidfd_open():
  function can_use_kqueue (line 257) | def can_use_kqueue():
  function wait_pid (line 289) | def wait_pid(pid, timeout=None):
  function disk_usage (line 307) | def disk_usage(path):
  function get_terminal_map (line 344) | def get_terminal_map():

FILE: psutil/_pssunos.py
  function virtual_memory (line 97) | def virtual_memory():
  function swap_memory (line 108) | def swap_memory():
  function cpu_times (line 153) | def cpu_times():
  function per_cpu_times (line 159) | def per_cpu_times():
  function cpu_count_logical (line 165) | def cpu_count_logical():
  function cpu_count_cores (line 174) | def cpu_count_cores():
  function cpu_stats (line 179) | def cpu_stats():
  function disk_partitions (line 195) | def disk_partitions(all=False):
  function net_connections (line 230) | def net_connections(kind, _pid=-1):
  function net_if_stats (line 261) | def net_if_stats():
  function boot_time (line 276) | def boot_time():
  function users (line 281) | def users():
  function pids (line 305) | def pids():
  function pid_exists (line 311) | def pid_exists(pid):
  function wrap_exceptions (line 316) | def wrap_exceptions(fun):
  class Process (line 345) | class Process:
    method __init__ (line 350) | def __init__(self, pid):
    method _assert_alive (line 356) | def _assert_alive(self):
    method oneshot_enter (line 362) | def oneshot_enter(self):
    method oneshot_exit (line 367) | def oneshot_exit(self):
    method _proc_name_and_args (line 374) | def _proc_name_and_args(self):
    method _oneshot (line 379) | def _oneshot(self):
    method _proc_cred (line 390) | def _proc_cred(self):
    method name (line 394) | def name(self):
    method exe (line 399) | def exe(self):
    method cmdline (line 411) | def cmdline(self):
    method environ (line 415) | def environ(self):
    method create_time (line 419) | def create_time(self):
    method num_threads (line 423) | def num_threads(self):
    method nice_get (line 427) | def nice_get(self):
    method nice_set (line 434) | def nice_set(self, value):
    method ppid (line 444) | def ppid(self):
    method uids (line 449) | def uids(self):
    method gids (line 459) | def gids(self):
    method cpu_times (line 469) | def cpu_times(self):
    method cpu_num (line 487) | def cpu_num(self):
    method terminal (line 491) | def terminal(self):
    method cwd (line 506) | def cwd(self):
    method memory_info (line 519) | def memory_info(self):
    method status (line 526) | def status(self):
    method threads (line 532) | def threads(self):
    method open_files (line 566) | def open_files(self):
    method _get_unix_sockets (line 586) | def _get_unix_sockets(self, pid):
    method net_connections (line 628) | def net_connections(self, kind='inet'):
    method memory_maps (line 650) | def memory_maps(self):
    method num_fds (line 695) | def num_fds(self):
    method num_ctx_switches (line 699) | def num_ctx_switches(self):
    method page_faults (line 705) | def page_faults(self):
    method wait (line 710) | def wait(self, timeout=None):

FILE: psutil/_psutil_aix.c
  function psutil_file_to_struct (line 64) | int
  function PyObject (line 93) | static PyObject *
  function PyObject (line 141) | static PyObject *
  function PyObject (line 161) | static PyObject *
  function PyObject (line 214) | static PyObject *
  function PyObject (line 288) | static PyObject *
  function PyObject (line 356) | static PyObject *
  function PyObject (line 387) | static PyObject *
  function PyObject (line 413) | static PyObject *
  function PyObject (line 440) | static PyObject *
  function PyObject (line 480) | static PyObject *
  function PyObject (line 537) | static PyObject *
  function PyObject (line 610) | static PyObject *
  function PyObject (line 661) | static PyObject *
  function PyObject (line 688) | static PyObject *
  function PyObject (line 755) | static PyObject *
  function PyObject (line 818) | static PyObject *
  function PyObject (line 846) | static PyObject *
  function PyObject (line 873) | static PyObject *
  type module_state (line 966) | struct module_state {
  function psutil_aix_traverse (line 976) | static int
  function psutil_aix_clear (line 982) | static int
  type PyModuleDef (line 988) | struct PyModuleDef
  type module_state (line 992) | struct module_state
  function PyMODINIT_FUNC (line 1001) | PyMODINIT_FUNC

FILE: psutil/_psutil_bsd.c
  type PyModuleDef (line 101) | struct PyModuleDef
  function PyObject (line 113) | PyObject *

FILE: psutil/_psutil_linux.c
  type PyModuleDef (line 50) | struct PyModuleDef
  function PyObject (line 63) | PyObject *

FILE: psutil/_psutil_osx.c
  type PyModuleDef (line 65) | struct PyModuleDef
  function PyObject (line 78) | PyObject *

FILE: psutil/_psutil_sunos.c
  type module_state (line 67) | struct module_state {
  type PyModuleDef (line 72) | struct PyModuleDef
  function PyObject (line 85) | PyObject *

FILE: psutil/_psutil_windows.c
  type module_state (line 112) | struct module_state {
  function psutil_windows_traverse (line 117) | static int
  function psutil_windows_clear (line 123) | static int
  type PyModuleDef (line 129) | struct PyModuleDef
  type module_state (line 133) | struct module_state
  function PyMODINIT_FUNC (line 142) | PyMODINIT_FUNC

FILE: psutil/_pswindows.py
  function convert_dos_path (line 94) | def convert_dos_path(s):
  function getpagesize (line 116) | def getpagesize():
  function virtual_memory (line 125) | def virtual_memory():
  function swap_memory (line 139) | def swap_memory():
  function disk_usage (line 180) | def disk_usage(path):
  function disk_partitions (line 191) | def disk_partitions(all):
  function cpu_times (line 202) | def cpu_times():
  function per_cpu_times (line 216) | def per_cpu_times():
  function cpu_count_logical (line 225) | def cpu_count_logical():
  function cpu_count_cores (line 230) | def cpu_count_cores():
  function cpu_stats (line 235) | def cpu_stats():
  function cpu_freq (line 242) | def cpu_freq():
  function _getloadavg_impl (line 255) | def _getloadavg_impl():
  function getloadavg (line 261) | def getloadavg():
  function net_connections (line 283) | def net_connections(kind, _pid=-1):
  function net_if_stats (line 306) | def net_if_stats():
  function net_io_counters (line 317) | def net_io_counters():
  function net_if_addrs (line 324) | def net_if_addrs():
  function sensors_battery (line 334) | def sensors_battery():
  function boot_time (line 361) | def boot_time():
  function users (line 377) | def users():
  function win_service_iter (line 393) | def win_service_iter():
  function win_service_get (line 399) | def win_service_get(name):
  class WindowsService (line 406) | class WindowsService:  # noqa: PLW1641
    method __init__ (line 409) | def __init__(self, name: str, display_name: str):
    method __str__ (line 413) | def __str__(self):
    method __repr__ (line 417) | def __repr__(self):
    method __eq__ (line 420) | def __eq__(self, other: object):
    method __ne__ (line 427) | def __ne__(self, other: object):
    method _query_config (line 430) | def _query_config(self):
    method _query_status (line 443) | def _query_status(self):
    method _wrap_exceptions (line 451) | def _wrap_exceptions(self):
    method name (line 475) | def name(self) -> str:
    method display_name (line 482) | def display_name(self) -> str:
    method binpath (line 488) | def binpath(self) -> str:
    method username (line 494) | def username(self) -> str:
    method start_type (line 498) | def start_type(self) -> str:
    method pid (line 506) | def pid(self) -> int | None:
    method status (line 512) | def status(self) -> str:
    method description (line 516) | def description(self) -> str:
    method as_dict (line 522) | def as_dict(self) -> dict[str, str | int | None]:
  function is_permission_err (line 583) | def is_permission_err(exc):
  function convert_oserror (line 592) | def convert_oserror(exc, pid=None, name=None):
  function wrap_exceptions (line 602) | def wrap_exceptions(fun):
  function retry_error_partial_copy (line 615) | def retry_error_partial_copy(fun):
  class Process (line 643) | class Process:
    method __init__ (line 648) | def __init__(self, pid):
    method oneshot_enter (line 655) | def oneshot_enter(self):
    method oneshot_exit (line 659) | def oneshot_exit(self):
    method _oneshot (line 664) | def _oneshot(self):
    method name (line 670) | def name(self):
    method exe (line 684) | def exe(self):
    method cmdline (line 703) | def cmdline(self):
    method environ (line 719) | def environ(self):
    method ppid (line 723) | def ppid(self):
    method _get_raw_meminfo (line 729) | def _get_raw_meminfo(self):
    method memory_info (line 755) | def memory_info(self):
    method memory_info_ex (line 782) | def memory_info_ex(self):
    method memory_footprint (line 795) | def memory_footprint(self):
    method page_faults (line 801) | def page_faults(self):
    method memory_maps (line 805) | def memory_maps(self):
    method kill (line 819) | def kill(self):
    method send_signal (line 823) | def send_signal(self, sig):
    method wait (line 836) | def wait(self, timeout=None):
    method username (line 877) | def username(self):
    method create_time (line 884) | def create_time(self, fast_only=False):
    method num_threads (line 899) | def num_threads(self):
    method threads (line 903) | def threads(self):
    method cpu_times (line 912) | def cpu_times(self):
    method suspend (line 926) | def suspend(self):
    method resume (line 930) | def resume(self):
    method cwd (line 935) | def cwd(self):
    method open_files (line 944) | def open_files(self):
    method net_connections (line 961) | def net_connections(self, kind='inet'):
    method nice_get (line 965) | def nice_get(self):
    method nice_set (line 971) | def nice_set(self, value):
    method ionice_get (line 975) | def ionice_get(self):
    method ionice_set (line 981) | def ionice_set(self, ioclass, value):
    method io_counters (line 991) | def io_counters(self):
    method status (line 1010) | def status(self):
    method cpu_affinity_get (line 1018) | def cpu_affinity_get(self):
    method cpu_affinity_set (line 1026) | def cpu_affinity_set(self, value):
    method num_handles (line 1052) | def num_handles(self):
    method num_ctx_switches (line 1062) | def num_ctx_switches(self):

FILE: psutil/arch/aix/common.c
  function psutil_kread (line 17) | int
  type procentry64 (line 42) | struct procentry64
  type procentry64 (line 46) | struct procentry64
  type procentry64 (line 46) | struct procentry64
  type procentry64 (line 47) | struct procentry64
  type procentry64 (line 53) | struct procentry64
  type fdsinfo64 (line 61) | struct fdsinfo64
  type procentry64 (line 68) | struct procentry64
  type procentry64 (line 75) | struct procentry64

FILE: psutil/arch/aix/common.h
  type u_longlong_t (line 18) | typedef u_longlong_t KA_T;
  type procentry64 (line 28) | struct procentry64

FILE: psutil/arch/aix/ifaddrs.c
  type sockaddr (line 28) | struct sockaddr
  type sockaddr (line 29) | struct sockaddr
  type sockaddr (line 30) | struct sockaddr
  type sockaddr (line 32) | struct sockaddr
  function freeifaddrs (line 40) | void
  function getifaddrs (line 53) | int

FILE: psutil/arch/aix/ifaddrs.h
  type ifaddrs (line 23) | struct ifaddrs {
  type ifaddrs (line 32) | struct ifaddrs
  type ifaddrs (line 33) | struct ifaddrs

FILE: psutil/arch/aix/net_connections.c
  function read_unp_addr (line 37) | static int
  function PyObject (line 67) | static PyObject *
  function PyObject (line 233) | PyObject *

FILE: psutil/arch/aix/net_kernel_structs.h
  type file64 (line 35) | struct file64 {
  type socket64 (line 43) | struct socket64 {
  type protosw64 (line 52) | struct protosw64 {
  type inpcb64 (line 59) | struct inpcb64 {
  type tcpcb64 (line 80) | struct tcpcb64 {
  type unpcb64 (line 86) | struct unpcb64 {
  type m_hdr64 (line 96) | struct m_hdr64 {
  type mbuf64 (line 103) | struct mbuf64 {

FILE: psutil/arch/all/errors.c
  function PyObject (line 20) | PyObject *
  function PyObject (line 34) | PyObject *
  function PyObject (line 56) | PyObject *
  function PyObject (line 72) | PyObject *
  function PyObject (line 91) | PyObject *
  function psutil_badargs (line 103) | int

FILE: psutil/arch/all/init.c
  function PyObject (line 23) | PyObject *
  function psutil_setup (line 45) | int

FILE: psutil/arch/all/pids.c
  function PyObject (line 15) | PyObject *
  function PyObject (line 34) | PyObject *

FILE: psutil/arch/all/str.c
  function _error (line 18) | static int
  function str_format (line 38) | int
  function str_copy (line 65) | int
  function str_append (line 83) | int

FILE: psutil/arch/all/utils.c
  function pylist_append_fmt (line 10) | int
  function pylist_append_obj (line 36) | int
  function pydict_add (line 53) | int
  function psutil_usage_percent (line 75) | double

FILE: psutil/arch/bsd/cpu.c
  function PyObject (line 16) | PyObject *
  function PyObject (line 33) | PyObject *

FILE: psutil/arch/bsd/disk.c
  function PyObject (line 20) | PyObject *

FILE: psutil/arch/bsd/heap.c
  function PyObject (line 23) | PyObject *
  function PyObject (line 67) | PyObject *

FILE: psutil/arch/bsd/init.c
  function convert_kvm_err (line 14) | void

FILE: psutil/arch/bsd/init.h
  type kinfo_file (line 15) | struct kinfo_file

FILE: psutil/arch/bsd/mem.c
  function PyObject (line 18) | PyObject *

FILE: psutil/arch/bsd/net.c
  function PyObject (line 17) | PyObject *

FILE: psutil/arch/bsd/proc.c
  function PyObject (line 26) | PyObject *
  function PyObject (line 195) | PyObject *
  type kinfo_proc2 (line 227) | struct kinfo_proc2
  type kinfo_proc (line 229) | struct kinfo_proc
  function PyObject (line 359) | PyObject *

FILE: psutil/arch/bsd/proc_utils.c
  function psutil_kinfo_proc (line 25) | int
  type kinfo_file (line 65) | struct kinfo_file
  type kinfo_file (line 74) | struct kinfo_file
  type kinfo_file (line 80) | struct kinfo_file
  type kinfo_file (line 88) | struct kinfo_file
  type kinfo_file (line 95) | struct kinfo_file
  function is_zombie (line 101) | int

FILE: psutil/arch/bsd/sys.c
  function PyObject (line 15) | PyObject *

FILE: psutil/arch/freebsd/cpu.c
  function PyObject (line 26) | PyObject *
  function PyObject (line 83) | PyObject *
  function PyObject (line 104) | PyObject *
  function PyObject (line 140) | PyObject *

FILE: psutil/arch/freebsd/disk.c
  function PyObject (line 19) | PyObject *

FILE: psutil/arch/freebsd/mem.c
  function sbn (line 23) | static inline int
  function PyObject (line 29) | PyObject *
  function PyObject (line 107) | PyObject *

FILE: psutil/arch/freebsd/pids.c
  function _psutil_pids (line 16) | int

FILE: psutil/arch/freebsd/proc.c
  function psutil_remove_spaces (line 22) | static void
  function PyObject (line 41) | PyObject *
  function PyObject (line 91) | PyObject *
  function PyObject (line 135) | PyObject *
  function PyObject (line 148) | PyObject *
  function PyObject (line 206) | PyObject *
  function PyObject (line 255) | PyObject *
  function PyObject (line 280) | PyObject *
  function PyObject (line 414) | PyObject *
  function PyObject (line 452) | PyObject *
  function PyObject (line 505) | PyObject *
  function PyObject (line 537) | PyObject *

FILE: psutil/arch/freebsd/proc_socks.c
  function psutil_sockaddr_port (line 51) | static int
  type sockaddr_storage (line 68) | struct sockaddr_storage
  type sockaddr_in6 (line 69) | struct sockaddr_in6
  type sockaddr_in (line 70) | struct sockaddr_in
  type sockaddr_in (line 73) | struct sockaddr_in
  type sockaddr_in6 (line 77) | struct sockaddr_in6
  function socklen_t (line 83) | static socklen_t
  function psutil_sockaddr_matches (line 92) | static int
  type xtcpcb (line 110) | struct xtcpcb
  type kinfo_file (line 111) | struct kinfo_file
  type xtcpcb (line 112) | struct xtcpcb
  type xinpcb (line 113) | struct xinpcb
  type tcpcb (line 115) | struct tcpcb
  type kinfo_file (line 116) | struct kinfo_file
  type tcpcb (line 117) | struct tcpcb
  type inpcb (line 118) | struct inpcb
  type xinpgen (line 120) | struct xinpgen
  type xsocket (line 121) | struct xsocket
  type xinpgen (line 123) | struct xinpgen
  type xinpgen (line 124) | struct xinpgen
  type xinpgen (line 125) | struct xinpgen
  type xinpgen (line 126) | struct xinpgen
  type xtcpcb (line 129) | struct xtcpcb
  type xtcpcb (line 133) | struct xtcpcb
  type xtcpcb (line 134) | struct xtcpcb
  type xtcpcb (line 135) | struct xtcpcb
  function PyObject (line 202) | PyObject *

FILE: psutil/arch/freebsd/sensors.c
  function PyObject (line 25) | PyObject *
  function PyObject (line 51) | PyObject *

FILE: psutil/arch/freebsd/sys_socks.c
  function psutil_populate_xfiles (line 29) | static int
  type xfile (line 56) | struct xfile
  type xfile (line 58) | struct xfile
  type xfile (line 60) | struct xfile
  function psutil_gather_inet (line 73) | static int
  function psutil_gather_unix (line 245) | static int
  function psutil_int_in_seq (line 360) | static int
  function PyObject (line 374) | PyObject *

FILE: psutil/arch/linux/disk.c
  function PyObject (line 15) | PyObject *

FILE: psutil/arch/linux/heap.c
  type my_mallinfo2 (line 17) | struct my_mallinfo2 {
  function PyObject (line 33) | PyObject *
  function PyObject (line 83) | PyObject *

FILE: psutil/arch/linux/mem.c
  function PyObject (line 13) | PyObject *

FILE: psutil/arch/linux/net.c
  type __u64 (line 20) | typedef __u64 u64;
  type __u32 (line 21) | typedef __u32 u32;
  type __u16 (line 22) | typedef __u16 u16;
  type __u8 (line 23) | typedef __u8 u8;
  function psutil_ethtool_cmd_speed (line 33) | static inline uint32_t
  function PyObject (line 56) | PyObject *

FILE: psutil/arch/linux/proc.c
  function ioprio_get (line 24) | static inline int
  function ioprio_set (line 29) | static inline int
  function PyObject (line 43) | PyObject *
  function PyObject (line 61) | PyObject *
  function PyObject (line 85) | PyObject *
  function PyObject (line 145) | PyObject *

FILE: psutil/arch/netbsd/cpu.c
  function PyObject (line 26) | PyObject *
  function PyObject (line 46) | PyObject *

FILE: psutil/arch/netbsd/disk.c
  function PyObject (line 23) | PyObject *

FILE: psutil/arch/netbsd/mem.c
  function PyObject (line 29) | PyObject *

FILE: psutil/arch/netbsd/pids.c
  function _psutil_pids (line 16) | int

FILE: psutil/arch/netbsd/proc.c
  function PyObject (line 17) | PyObject *
  function PyObject (line 110) | PyObject *
  function PyObject (line 123) | PyObject *
  function PyObject (line 195) | PyObject *
  function PyObject (line 264) | PyObject *

FILE: psutil/arch/netbsd/socks.c
  type kif (line 20) | struct kif {
  type kpcb (line 32) | struct kpcb {
  function psutil_kiflist_init (line 44) | static void
  function psutil_kiflist_clear (line 51) | static void
  function psutil_kpcblist_init (line 64) | static void
  function psutil_kpcblist_clear (line 71) | static void
  function psutil_get_files (line 84) | static int
  function psutil_get_sockets (line 153) | static int
  function psutil_get_info (line 223) | static int
  function PyObject (line 310) | PyObject *

FILE: psutil/arch/openbsd/cpu.c
  function PyObject (line 15) | PyObject *
  function PyObject (line 64) | PyObject *
  function PyObject (line 85) | PyObject *

FILE: psutil/arch/openbsd/disk.c
  function PyObject (line 15) | PyObject *

FILE: psutil/arch/openbsd/mem.c
  function PyObject (line 17) | PyObject *

FILE: psutil/arch/openbsd/pids.c
  function _psutil_pids (line 16) | int

FILE: psutil/arch/openbsd/proc.c
  function PyObject (line 20) | PyObject *
  function PyObject (line 61) | PyObject *
  function PyObject (line 135) | PyObject *
  function PyObject (line 169) | PyObject *

FILE: psutil/arch/openbsd/socks.c
  function PyObject (line 20) | PyObject *

FILE: psutil/arch/openbsd/users.c
  function PyObject (line 14) | PyObject *

FILE: psutil/arch/osx/cpu.c
  function PyObject (line 41) | PyObject *
  function PyObject (line 51) | PyObject *
  function PyObject (line 61) | PyObject *
  function PyObject (line 95) | PyObject *
  function psutil_find_pmgr_entry (line 140) | static int
  function PyObject (line 176) | PyObject *
  function PyObject (line 188) | PyObject *
  function PyObject (line 242) | PyObject *
  function PyObject (line 247) | PyObject *
  function PyObject (line 276) | PyObject *

FILE: psutil/arch/osx/disk.c
  function PyObject (line 28) | PyObject *
  function PyObject (line 163) | PyObject *
  function PyObject (line 218) | PyObject *

FILE: psutil/arch/osx/heap.c
  function get_zones (line 16) | static int
  function PyObject (line 64) | PyObject *
  function PyObject (line 90) | PyObject *

FILE: psutil/arch/osx/init.c
  function psutil_setup_osx (line 17) | int

FILE: psutil/arch/osx/init.h
  type kinfo_proc (line 19) | struct kinfo_proc
  type proc_fdinfo (line 25) | struct proc_fdinfo

FILE: psutil/arch/osx/mem.c
  function psutil_sys_vminfo (line 22) | static int
  function PyObject (line 54) | PyObject *
  function PyObject (line 109) | PyObject *

FILE: psutil/arch/osx/net.c
  function PyObject (line 21) | PyObject *

FILE: psutil/arch/osx/pids.c
  function _psutil_pids (line 16) | int

FILE: psutil/arch/osx/proc.c
  function convert_status (line 38) | static int
  function PyObject (line 71) | PyObject *
  function PyObject (line 129) | PyObject *
  function PyObject (line 181) | PyObject *
  function PyObject (line 198) | PyObject *
  function PyObject (line 221) | PyObject *
  function psutil_in_shared_region (line 256) | static bool
  function PyObject (line 285) | PyObject *
  function PyObject (line 341) | PyObject *
  function PyObject (line 445) | PyObject *
  function PyObject (line 565) | PyObject *
  function PyObject (line 654) | PyObject *
  function PyObject (line 892) | PyObject *
  function PyObject (line 911) | PyObject *
  function PyObject (line 999) | PyObject *

FILE: psutil/arch/osx/proc_utils.c
  function psutil_get_kinfo_proc (line 23) | int
  function is_zombie (line 53) | int
  function psutil_sysctl_procargs (line 67) | int
  function psutil_proc_pidinfo (line 118) | int
  function psutil_task_for_pid (line 158) | int
  type proc_fdinfo (line 197) | struct proc_fdinfo
  type proc_fdinfo (line 202) | struct proc_fdinfo

FILE: psutil/arch/osx/sensors.c
  function PyObject (line 22) | PyObject *

FILE: psutil/arch/osx/sys.c
  function PyObject (line 17) | PyObject *

FILE: psutil/arch/posix/init.c
  function psutil_getpagesize (line 26) | long
  function PyObject (line 42) | PyObject *
  function psutil_posix_add_methods (line 71) | int
  function psutil_posix_add_constants (line 98) | int

FILE: psutil/arch/posix/net.c
  function PyObject (line 53) | PyObject *
  function PyObject (line 126) | PyObject *
  function PyObject (line 216) | PyObject *
  function append_flag (line 244) | static int
  function PyObject (line 252) | PyObject *
  function PyObject (line 442) | PyObject *
  function psutil_get_nic_speed (line 477) | int
  function PyObject (line 621) | PyObject *

FILE: psutil/arch/posix/pids.c
  function has_pid_zero (line 14) | static int
  function psutil_pid_exists (line 28) | int

FILE: psutil/arch/posix/proc.c
  function PyObject (line 18) | PyObject *
  function else (line 43) | else if (is_zombie(pid))
  function PyObject (line 74) | PyObject *

FILE: psutil/arch/posix/sysctl.c
  function psutil_sysctl (line 19) | int
  function psutil_sysctl_malloc (line 42) | int
  function psutil_sysctl_argmax (line 108) | size_t
  function psutil_sysctlbyname (line 128) | int
  function psutil_sysctlbyname_malloc (line 161) | int

FILE: psutil/arch/posix/users.c
  function setup (line 16) | static void
  function teardown (line 23) | static void
  function PyObject (line 30) | PyObject *

FILE: psutil/arch/sunos/cpu.c
  function PyObject (line 16) | PyObject *
  function PyObject (line 64) | PyObject *
  function PyObject (line 100) | PyObject *

FILE: psutil/arch/sunos/disk.c
  function PyObject (line 16) | PyObject *
  function PyObject (line 73) | PyObject *

FILE: psutil/arch/sunos/environ.c
  function open_address_space (line 31) | static int
  function read_offt (line 54) | static size_t
  function is_ptr_dereference_possible (line 214) | static inline int
  function ptr_size_by_psinfo (line 230) | static inline int
  function search_pointers_vector_size_offt (line 243) | static int
  function psutil_free_cstrings_array (line 386) | void

FILE: psutil/arch/sunos/mem.c
  function PyObject (line 15) | PyObject *

FILE: psutil/arch/sunos/net.c
  function PyObject (line 28) | PyObject *
  function PyObject (line 144) | PyObject *
  function PyObject (line 261) | PyObject *

FILE: psutil/arch/sunos/proc.c
  function psutil_file_to_struct (line 16) | static int
  function PyObject (line 45) | PyObject *
  function PyObject (line 79) | PyObject *
  function PyObject (line 176) | PyObject *
  function PyObject (line 251) | PyObject *
  function PyObject (line 277) | PyObject *
  function PyObject (line 348) | PyObject *
  function PyObject (line 375) | PyObject *
  function PyObject (line 394) | PyObject *
  function PyObject (line 451) | PyObject *
  function PyObject (line 474) | PyObject *

FILE: psutil/arch/sunos/sys.c
  function PyObject (line 14) | PyObject *

FILE: psutil/arch/windows/cpu.c
  function psutil_get_num_cpus (line 18) | static unsigned int
  function PyObject (line 48) | PyObject *
  function PyObject (line 76) | PyObject *
  function PyObject (line 157) | PyObject *
  function PyObject (line 172) | PyObject *
  function PyObject (line 255) | PyObject *
  function PyObject (line 370) | PyObject *

FILE: psutil/arch/windows/disk.c
  function PyObject (line 42) | PyObject *
  function PyObject (line 80) | PyObject *
  function PyObject (line 210) | PyObject *
  function PyObject (line 379) | PyObject *

FILE: psutil/arch/windows/heap.c
  function PyObject (line 26) | PyObject *
  function PyObject (line 97) | PyObject *

FILE: psutil/arch/windows/init.c
  function PyObject (line 27) | PyObject *
  function PyObject (line 65) | PyObject *
  function PVOID (line 83) | PVOID
  function PVOID (line 100) | PVOID
  function PVOID (line 122) | PVOID
  function _to_unix_time (line 153) | static double
  function psutil_FiletimeToUnixTime (line 167) | double
  function psutil_LargeIntegerToUnixTime (line 175) | double
  function psutil_loadlibs (line 186) | static int
  function psutil_set_winver (line 282) | static int
  function psutil_setup_windows (line 310) | int

FILE: psutil/arch/windows/mem.c
  function PyObject (line 15) | PyObject *
  function PyObject (line 23) | PyObject *
  function PyObject (line 60) | PyObject *

FILE: psutil/arch/windows/net.c
  function PIP_ADAPTER_ADDRESSES (line 18) | static PIP_ADAPTER_ADDRESSES
  function PyObject (line 52) | PyObject *
  function PyObject (line 132) | PyObject *
  function PyObject (line 341) | PyObject *

FILE: psutil/arch/windows/ntextapi.h
  type LONG (line 14) | typedef LONG NTSTATUS;
  type KTHREAD_STATE (line 47) | typedef enum _KTHREAD_STATE {
  type KWAIT_REASON (line 60) | typedef enum _KWAIT_REASON {
  type WTS_INFO_CLASS (line 104) | typedef enum _WTS_INFO_CLASS {
  type WTS_CONNECTSTATE_CLASS (line 137) | typedef enum _WTS_CONNECTSTATE_CLASS {
  type _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION (line 155) | typedef struct {
  type _SYSTEM_PERFORMANCE_INFORMATION (line 165) | typedef struct {
  type _SYSTEM_INTERRUPT_INFORMATION (line 243) | typedef struct {
  type SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX (line 252) | typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX {
  type SYSTEM_HANDLE_INFORMATION_EX (line 263) | typedef struct _SYSTEM_HANDLE_INFORMATION_EX {
  type CLIENT_ID2 (line 269) | typedef struct _CLIENT_ID2 {
  type SYSTEM_THREAD_INFORMATION2 (line 277) | typedef struct _SYSTEM_THREAD_INFORMATION2 {
  type SYSTEM_PROCESS_INFORMATION2 (line 294) | typedef struct _SYSTEM_PROCESS_INFORMATION2 {
  type PROCESSOR_POWER_INFORMATION (line 336) | typedef struct _PROCESSOR_POWER_INFORMATION {
  type IN6_ADDR (line 346) | typedef struct in6_addr {
  type RTL_USER_PROCESS_PARAMETERS_ (line 355) | typedef struct {
  type WTS_SESSION_INFOW (line 367) | typedef struct _WTS_SESSION_INFOW {
  type WTS_CLIENT_ADDRESS (line 376) | typedef struct _WTS_CLIENT_ADDRESS {
  type WTSINFOW (line 381) | typedef struct _WTSINFOW {
  type DUMMYUNIONNAME (line 406) | typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX {
  type MEMORY_WORKING_SET_BLOCK (line 421) | typedef struct _MEMORY_WORKING_SET_BLOCK {
  type MEMORY_WORKING_SET_INFORMATION (line 434) | typedef struct _MEMORY_WORKING_SET_INFORMATION {
  type PSUTIL_PROCESS_WS_COUNTERS (line 440) | typedef struct _PSUTIL_PROCESS_WS_COUNTERS {
  type SYSTEM_PROCESS_ID_INFORMATION (line 448) | typedef struct _SYSTEM_PROCESS_ID_INFORMATION {
  type PEB_ (line 458) | typedef struct {
  type UNICODE_STRING32 (line 469) | typedef struct {
  type RTL_USER_PROCESS_PARAMETERS32 (line 475) | typedef struct {
  type PEB32 (line 486) | typedef struct {
  type PEB_ (line 496) | typedef struct {
  type PROCESS_BASIC_INFORMATION64 (line 516) | typedef struct {
  type UNICODE_STRING64 (line 524) | typedef struct {
  type RTL_USER_PROCESS_PARAMETERS64 (line 530) | typedef struct {
  type PEB64 (line 541) | typedef struct {

FILE: psutil/arch/windows/pids.c
  function _psutil_pids (line 14) | int

FILE: psutil/arch/windows/proc.c
  function PyObject (line 37) | PyObject *
  function PyObject (line 55) | PyObject *
  function PyObject (line 89) | PyObject *
  function PyObject (line 162) | PyObject *
  function PyObject (line 215) | PyObject *
  function PyObject (line 325) | PyObject *
  function psutil_GetProcWsetInformation (line 371) | static int
  function PyObject (line 438) | PyObject *
  function PyObject (line 489) | PyObject *
  function PyObject (line 519) | PyObject *
  function PyObject (line 623) | PyObject *
  function PTOKEN_USER (line 643) | static PTOKEN_USER
  function PyObject (line 701) | PyObject *
  function PyObject (line 802) | PyObject *
  function PyObject (line 829) | PyObject *
  function PyObject (line 858) | PyObject *
  function PyObject (line 886) | PyObject *
  function PyObject (line 915) | PyObject *
  function PyObject (line 949) | PyObject *
  function PyObject (line 976) | PyObject *
  function PyObject (line 1006) | PyObject *
  function PyObject (line 1030) | PyObject *
  function PyObject (line 1057) | PyObject *
  function PyObject (line 1106) | PyObject *
  function PyObject (line 1176) | PyObject *

FILE: psutil/arch/windows/proc_handles.c
  function psutil_enum_handles (line 33) | static int
  function psutil_get_filename (line 81) | static int
  function DWORD (line 147) | static DWORD
  function PyObject (line 210) | PyObject *

FILE: psutil/arch/windows/proc_info.c
  function psutil_get_process_region_size (line 42) | static int
  type psutil_process_data_kind (line 56) | enum psutil_process_data_kind {
  function psutil_convert_winerr (line 63) | static void
  function psutil_convert_ntstatus_err (line 78) | static void
  function psutil_giveup_with_ad (line 90) | static void
  function psutil_get_process_data (line 114) | static int
  function psutil_cmdline_query_proc (line 457) | static int
  function PyObject (line 548) | PyObject *
  function PyObject (line 636) | PyObject *
  function PyObject (line 671) | PyObject *
  function psutil_get_proc_info (line 712) | int
  function PyObject (line 791) | PyObject *

FILE: psutil/arch/windows/proc_utils.c
  function psutil_pid_in_pids (line 17) | int
  function HANDLE (line 41) | HANDLE
  function HANDLE (line 101) | HANDLE
  function psutil_pid_is_running (line 123) | int

FILE: psutil/arch/windows/security.c
  function BOOL (line 16) | static BOOL
  function HANDLE (line 68) | static HANDLE
  function psutil_print_err (line 98) | static void
  function psutil_set_se_debug (line 117) | int

FILE: psutil/arch/windows/sensors.c
  function PyObject (line 15) | PyObject *

FILE: psutil/arch/windows/services.c
  function SC_HANDLE (line 19) | SC_HANDLE
  function SC_HANDLE (line 46) | static SC_HANDLE
  function PyObject (line 128) | PyObject *
  function PyObject (line 219) | PyObject *
  function PyObject (line 319) | PyObject *
  function PyObject (line 394) | PyObject *
  function PyObject (line 479) | PyObject *
  function PyObject (line 514) | PyObject *

FILE: psutil/arch/windows/socks.c
  function PVOID (line 28) | static PVOID
  function PVOID (line 60) | static PVOID
  function PyObject (line 102) | PyObject *

FILE: psutil/arch/windows/sys.c
  function PyObject (line 28) | PyObject *
  function PyObject (line 46) | PyObject *

FILE: psutil/arch/windows/wmi.c
  function VOID (line 46) | VOID CALLBACK
  function PyObject (line 72) | PyObject *
  function PyObject (line 132) | PyObject *

FILE: scripts/battery.py
  function secs2hours (line 21) | def secs2hours(secs):
  function main (line 27) | def main():

FILE: scripts/cpu_distribution.py
  function clean_screen (line 53) | def clean_screen():
  function main (line 60) | def main():

FILE: scripts/disk_usage.py
  function main (line 25) | def main():

FILE: scripts/fans.py
  function main (line 19) | def main():

FILE: scripts/free.py
  function main (line 18) | def main():

FILE: scripts/ifconfig.py
  function main (line 63) | def main():

FILE: scripts/internal/bench_oneshot.py
  function main (line 124) | def main():

FILE: scripts/internal/bench_oneshot_2.py
  function call_normal (line 20) | def call_normal(funs):
  function call_oneshot (line 25) | def call_oneshot(funs):
  function main (line 31) | def main():

FILE: scripts/internal/convert_readme.py
  function main (line 27) | def main():

FILE: scripts/internal/download_wheels.py
  function safe_rmpath (line 41) | def safe_rmpath(path):
  function get_artifacts (line 52) | def get_artifacts():
  function download_zip (line 63) | def download_zip(url):
  function run (line 77) | def run():
  function main (line 85) | def main():

FILE: scripts/internal/find_adopters.py
  function stderr (line 75) | def stderr(msg="", color=None):
  function graphql (line 82) | def graphql(session, query, variables=None):
  function get_session (line 103) | def get_session(token):
  function enumerate_repos (line 113) | def enumerate_repos(session):
  function fetch_readmes (line 189) | def fetch_readmes(session, repos):
  function _build_fixed_dep_fragment (line 240) | def _build_fixed_dep_fragment():
  function _make_req_alias (line 262) | def _make_req_alias(filename):
  function fetch_dep_files (line 269) | def fetch_dep_files(session, repos):
  function classify_dependency (line 380) | def classify_dependency(file_contents):
  function make_subst_name (line 455) | def make_subst_name(full_name):
  function tier_label (line 463) | def tier_label(stars):
  function generate_rst (line 472) | def generate_rst(projects):
  function load_cache (line 569) | def load_cache():
  function save_cache (line 602) | def save_cache(repos, readmes, dep_files):
  function parse_cli (line 618) | def parse_cli():
  function main (line 715) | def main():

FILE: scripts/internal/find_broken_links.py
  function memoize (line 62) | def memoize(fun):
  function sanitize_url (line 78) | def sanitize_url(url):
  function find_urls (line 90) | def find_urls(s):
  function parse_rst (line 95) | def parse_rst(fname):
  function parse_py (line 102) | def parse_py(fname):
  function parse_c (line 123) | def parse_c(fname):
  function parse_generic (line 154) | def parse_generic(fname):
  function get_urls (line 160) | def get_urls(fname):
  function validate_url (line 176) | def validate_url(url):
  function parallel_validator (line 191) | def parallel_validator(urls):
  function main (line 222) | def main():

FILE: scripts/internal/generate_manifest.py
  function sh (line 18) | def sh(cmd):
  function main (line 24) | def main():

FILE: scripts/internal/git_pre_commit.py
  function log (line 28) | def log(msg="", color=None, bold=None):
  function exit_with (line 35) | def exit_with(msg):
  function sh (line 40) | def sh(cmd):
  function git_commit_files (line 57) | def git_commit_files():
  function lint_manifest (line 74) | def lint_manifest():
  function run_make (line 84) | def run_make(target, files):
  function main (line 94) | def main():

FILE: scripts/internal/install_pip.py
  function main (line 25) | def main():

FILE: scripts/internal/print_access_denied.py
  function main (line 54) | def main():

FILE: scripts/internal/print_announce.py
  function rst_to_text (line 72) | def rst_to_text(s):
  function get_changes (line 88) | def get_changes():
  function main (line 128) | def main():

FILE: scripts/internal/print_api_speed.py
  function print_header (line 86) | def print_header(what):
  function print_timings (line 92) | def print_timings():
  function timecall (line 104) | def timecall(title, fun, *args, **kw):
  function set_highest_priority (line 118) | def set_highest_priority():
  function main (line 132) | def main():

FILE: scripts/internal/print_dist.py
  class Wheel (line 24) | class Wheel:
    method __init__ (line 25) | def __init__(self, path):
    method __repr__ (line 29) | def __repr__(self):
    method name (line 41) | def name(self):
    method platform (line 44) | def platform(self):
    method arch (line 66) | def arch(self):
    method pyver (line 77) | def pyver(self):
    method size (line 82) | def size(self):
  class Tarball (line 86) | class Tarball(Wheel):
    method platform (line 87) | def platform(self):
    method arch (line 90) | def arch(self):
    method pyver (line 93) | def pyver(self):
  function main (line 97) | def main():

FILE: scripts/internal/print_downloads.py
  function sh (line 39) | def sh(cmd):
  function query (line 58) | def query(cmd):
  function top_packages (line 65) | def top_packages():
  function ranking (line 74) | def ranking():
  function downloads (line 82) | def downloads():
  function downloads_pyver (line 90) | def downloads_pyver():
  function downloads_by_country (line 94) | def downloads_by_country():
  function downloads_by_system (line 98) | def downloads_by_system():
  function downloads_by_distro (line 102) | def downloads_by_distro():
  function print_row (line 112) | def print_row(left, right):
  function print_header (line 118) | def print_header(left, right="Downloads"):
  function print_markdown_table (line 124) | def print_markdown_table(title, left, rows):
  function main (line 135) | def main():

FILE: scripts/internal/print_hashes.py
  function csum (line 16) | def csum(file, kind):
  function main (line 23) | def main():

FILE: scripts/internal/print_sysinfo.py
  function sh (line 38) | def sh(cmd):
  function main (line 49) | def main():

FILE: scripts/internal/purge_installation.py
  function rmpath (line 22) | def rmpath(path):
  function purge (line 31) | def purge():
  function purge_windows (line 40) | def purge_windows():
  function main (line 72) | def main():

FILE: scripts/internal/rst_check_dead_refs.py
  function line_number (line 41) | def line_number(text, pos):
  function read_with_includes (line 45) | def read_with_includes(path, _seen=None):
  function main (line 65) | def main():

FILE: scripts/iotop.py
  function printl (line 47) | def printl(line, highlight=False):
  function poll (line 64) | def poll(interval):
  function refresh_window (line 113) | def refresh_window(procs, disks_read, disks_write):
  function setup (line 143) | def setup():
  function tear_down (line 152) | def tear_down():
  function main (line 159) | def main():

FILE: scripts/killall.py
  function main (line 15) | def main():

FILE: scripts/meminfo.py
  function pprint_ntuple (line 36) | def pprint_ntuple(nt):
  function main (line 44) | def main():

FILE: scripts/netstat.py
  function main (line 38) | def main():

FILE: scripts/nettop.py
  function printl (line 48) | def printl(line, highlight=False):
  function poll (line 65) | def poll(interval):
  function refresh_window (line 76) | def refresh_window(tot_before, tot_after, pnic_before, pnic_after):
  function setup (line 127) | def setup():
  function tear_down (line 136) | def tear_down():
  function main (line 143) | def main():

FILE: scripts/pidof.py
  function pidof (line 19) | def pidof(pgname):
  function main (line 29) | def main():

FILE: scripts/pmap.py
  function safe_print (line 38) | def safe_print(s):
  function main (line 46) | def main():

FILE: scripts/procinfo.py
  function print_ (line 120) | def print_(a, b):
  function str_ntuple (line 128) | def str_ntuple(nt, convert_bytes=False):
  function run (line 139) | def run(pid, verbose=False):
  function main (line 328) | def main():

FILE: scripts/procsmem.py
  function convert_bytes (line 46) | def convert_bytes(n):
  function main (line 58) | def main():

FILE: scripts/ps.py
  function main (line 42) | def main():

FILE: scripts/pstree.py
  function print_tree (line 36) | def print_tree(parent, tree, indent=''):
  function main (line 53) | def main():

FILE: scripts/sensors.py
  function secs2hours (line 33) | def secs2hours(secs):
  function main (line 39) | def main():

FILE: scripts/temperatures.py
  function main (line 29) | def main():

FILE: scripts/top.py
  function printl (line 52) | def printl(line, color=None, bold=False, highlight=False):
  function poll (line 76) | def poll(interval):
  function get_color (line 109) | def get_color(perc):
  function print_header (line 118) | def print_header(procs_status, num_procs):
  function refresh_window (line 180) | def refresh_window(procs, procs_status):
  function setup (line 236) | def setup():
  function tear_down (line 245) | def tear_down():
  function main (line 252) | def main():

FILE: scripts/who.py
  function main (line 20) | def main():

FILE: scripts/winservices.py
  function main (line 41) | def main():

FILE: setup.py
  function get_long_description (line 153) | def get_long_description():
  function silenced_output (line 169) | def silenced_output():
  function has_python_h (line 175) | def has_python_h():
  function get_sysdeps (line 180) | def get_sysdeps():
  function print_install_instructions (line 208) | def print_install_instructions():
  function unix_can_compile (line 224) | def unix_can_compile(c_code):
  function get_winver (line 253) | def get_winver():
  function main (line 418) | def main():

FILE: tests/__init__.py
  function macos_version (line 128) | def macos_version():
  function _get_py_exe (line 223) | def _get_py_exe():
  class ThreadTask (line 285) | class ThreadTask(threading.Thread):
    method __init__ (line 288) | def __init__(self):
    method __repr__ (line 294) | def __repr__(self):
    method __enter__ (line 298) | def __enter__(self):
    method __exit__ (line 302) | def __exit__(self, *args, **kwargs):
    method start (line 305) | def start(self):
    method run (line 314) | def run(self):
    method stop (line 320) | def stop(self):
  function _reap_children_on_err (line 333) | def _reap_children_on_err(fun):
  function spawn_subproc (line 346) | def spawn_subproc(cmd=None, **kwds):
  function spawn_children_pair (line 396) | def spawn_children_pair():
  function spawn_zombie (line 434) | def spawn_zombie():
  function pyrun (line 476) | def pyrun(src, **kwds):
  function sh (line 496) | def sh(cmd, **kwds):
  function terminate (line 520) | def terminate(proc_or_pid, sig=signal.SIGTERM, wait_timeout=GLOBAL_TIMEO...
  function reap_children (line 604) | def reap_children(recursive=False):
  function kernel_version (line 641) | def kernel_version():
  function get_winver (line 665) | def get_winver():
  class retry (line 678) | class retry:
    method __init__ (line 681) | def __init__(
    method __iter__ (line 697) | def __iter__(self):
    method sleep (line 709) | def sleep(self):
    method __call__ (line 713) | def __call__(self, fun):
  function wait_for_pid (line 741) | def wait_for_pid(pid):
  function wait_for_file (line 756) | def wait_for_file(fname, delete=True, empty=False):
  function call_until (line 773) | def call_until(fun):
  function safe_rmpath (line 785) | def safe_rmpath(path):
  function safe_mkdir (line 819) | def safe_mkdir(dir):
  function chdir (line 828) | def chdir(dirname):
  function create_py_exe (line 838) | def create_py_exe(path):
  function create_c_exe (line 849) | def create_c_exe(path, c_code=None):
  function get_testfn (line 875) | def get_testfn(suffix="", dir=None):
  class PsutilTestCase (line 892) | class PsutilTestCase(unittest.TestCase):
    method __str__ (line 901) | def __str__(self):
    method get_testfn (line 911) | def get_testfn(self, suffix="", dir=None):
    method spawn_subproc (line 916) | def spawn_subproc(self, *args, **kwds):
    method spawn_psproc (line 921) | def spawn_psproc(self, *args, **kwargs):
    method spawn_children_pair (line 929) | def spawn_children_pair(self):
    method spawn_zombie (line 935) | def spawn_zombie(self):
    method pyrun (line 941) | def pyrun(self, *args, **kwds):
    method _check_proc_exc (line 947) | def _check_proc_exc(self, proc, exc):
    method assert_pid_gone (line 960) | def assert_pid_gone(self, pid):
    method assert_proc_gone (line 975) | def assert_proc_gone(self, proc):
    method assert_proc_zombie (line 994) | def assert_proc_zombie(self, proc):
    method check_proc_memory (line 1064) | def check_proc_memory(self, nt):
  function is_win_secure_system_proc (line 1081) | def is_win_secure_system_proc(pid):
  function _get_eligible_cpu (line 1099) | def _get_eligible_cpu():
  class process_namespace (line 1108) | class process_namespace:
    method __init__ (line 1206) | def __init__(self, proc):
    method iter (line 1209) | def iter(self, ls, clear_cache=True):
    method clear_cache (line 1222) | def clear_cache(self):
    method test_class_coverage (line 1227) | def test_class_coverage(cls, test_class, ls):
    method test (line 1241) | def test(cls):
  class system_namespace (line 1250) | class system_namespace:
    method iter (line 1311) | def iter(ls):
  function retry_on_failure (line 1325) | def retry_on_failure(retries=NO_RETRIES):
  function skip_on_access_denied (line 1363) | def skip_on_access_denied(only_if=None):
  function skip_on_not_implemented (line 1382) | def skip_on_not_implemented(only_if=None):
  function get_free_port (line 1411) | def get_free_port(host='127.0.0.1'):
  function bind_socket (line 1418) | def bind_socket(family=AF_INET, type=SOCK_STREAM, addr=None):
  function bind_unix_socket (line 1435) | def bind_unix_socket(name, type=socket.SOCK_STREAM):
  function tcp_socketpair (line 1450) | def tcp_socketpair(family, addr=("", 0)):
  function unix_socketpair (line 1473) | def unix_socketpair(name):
  function create_sockets (line 1497) | def create_sockets():
  function check_net_address (line 1527) | def check_net_address(addr, family):
  function check_connection_ntuple (line 1547) | def check_connection_ntuple(conn):
  function filter_proc_net_connections (line 1623) | def filter_proc_net_connections(cons):
  class TypeHintsChecker (line 1642) | class TypeHintsChecker:
    method _get_ntuple_hints (line 1650) | def _get_ntuple_hints(nt):
    method _hint_to_types (line 1669) | def _hint_to_types(hint):
    method check_ntuple_type_hints (line 1695) | def check_ntuple_type_hints(nt):
    method _get_return_hint (line 1726) | def _get_return_hint(fun):
    method _check_container_items (line 1759) | def _check_container_items(hint, value):
    method check_fun_type_hints (line 1778) | def check_fun_type_hints(fun, retval):
  function reload_module (line 1803) | def reload_module(module):
  function import_module_by_path (line 1807) | def import_module_by_path(path):
  function warn (line 1818) | def warn(msg):
  function is_namedtuple (line 1823) | def is_namedtuple(x):
  function copyload_shared_lib (line 1837) | def copyload_shared_lib(suffix=""):
  function copyload_shared_lib (line 1861) | def copyload_shared_lib(suffix=""):
  function cleanup_test_procs (line 1913) | def cleanup_test_procs():

FILE: tests/test_aix.py
  class AIXSpecificTestCase (line 22) | class AIXSpecificTestCase(PsutilTestCase):
    method test_virtual_memory (line 23) | def test_virtual_memory(self):
    method test_swap_memory (line 57) | def test_swap_memory(self):
    method test_cpu_stats (line 80) | def test_cpu_stats(self):
    method test_cpu_count_logical (line 133) | def test_cpu_count_logical(self):
    method test_net_if_addrs_names (line 139) | def test_net_if_addrs_names(self):

FILE: tests/test_bsd.py
  function sysctl (line 42) | def sysctl(cmdline):
  function muse (line 57) | def muse(field):
  class BSDTestCase (line 74) | class BSDTestCase(PsutilTestCase):
    method setUpClass (line 78) | def setUpClass(cls):
    method tearDownClass (line 82) | def tearDownClass(cls):
    method test_process_create_time (line 86) | def test_process_create_time(self):
    method test_disks (line 95) | def test_disks(self):
    method test_cpu_count_logical (line 125) | def test_cpu_count_logical(self):
    method test_virtual_memory_total (line 135) | def test_virtual_memory_total(self):
    method test_net_if_stats (line 142) | def test_net_if_stats(self):
  class FreeBSDTestCase (line 160) | class FreeBSDTestCase(PsutilTestCase):
    method setUpClass (line 162) | def setUpClass(cls):
    method tearDownClass (line 166) | def tearDownClass(cls):
    method test_memory_maps (line 170) | def test_memory_maps(self):
    method test_exe (line 184) | def test_exe(self):
    method test_cmdline (line 188) | def test_cmdline(self):
    method test_uids_gids (line 194) | def test_uids_gids(self):
    method test_ctx_switches (line 208) | def test_ctx_switches(self):
    method test_cpu_times (line 228) | def test_cpu_times(self):
  class FreeBSDSystemTestCase (line 249) | class FreeBSDSystemTestCase(PsutilTestCase):
    method parse_swapinfo (line 251) | def parse_swapinfo():
    method test_cpu_frequency_against_sysctl (line 263) | def test_cpu_frequency_against_sysctl(self):
    method test_vmem_active (line 286) | def test_vmem_active(self):
    method test_vmem_inactive (line 291) | def test_vmem_inactive(self):
    method test_vmem_wired (line 296) | def test_vmem_wired(self):
    method test_vmem_cached (line 301) | def test_vmem_cached(self):
    method test_vmem_free (line 306) | def test_vmem_free(self):
    method test_vmem_buffers (line 311) | def test_vmem_buffers(self):
    method test_muse_vmem_total (line 318) | def test_muse_vmem_total(self):
    method test_muse_vmem_active (line 324) | def test_muse_vmem_active(self):
    method test_muse_vmem_inactive (line 330) | def test_muse_vmem_inactive(self):
    method test_muse_vmem_wired (line 336) | def test_muse_vmem_wired(self):
    method test_muse_vmem_cached (line 342) | def test_muse_vmem_cached(self):
    method test_muse_vmem_free (line 348) | def test_muse_vmem_free(self):
    method test_muse_vmem_buffers (line 354) | def test_muse_vmem_buffers(self):
    method test_cpu_stats_ctx_switches (line 358) | def test_cpu_stats_ctx_switches(self):
    method test_cpu_stats_interrupts (line 367) | def test_cpu_stats_interrupts(self):
    method test_cpu_stats_soft_interrupts (line 373) | def test_cpu_stats_soft_interrupts(self):
    method test_cpu_stats_syscalls (line 383) | def test_cpu_stats_syscalls(self):
    method test_swapmem_free (line 392) | def test_swapmem_free(self):
    method test_swapmem_used (line 396) | def test_swapmem_used(self):
    method test_swapmem_total (line 400) | def test_swapmem_total(self):
    method test_boot_time (line 406) | def test_boot_time(self):
    method test_sensors_battery (line 416) | def test_sensors_battery(self):
    method test_sensors_battery_against_sysctl (line 434) | def test_sensors_battery_against_sysctl(self):
    method test_sensors_battery_no_battery (line 448) | def test_sensors_battery_no_battery(self):
    method test_sensors_temperatures_against_sysctl (line 460) | def test_sensors_temperatures_against_sysctl(self):
  class OpenBSDTestCase (line 491) | class OpenBSDTestCase(PsutilTestCase):
    method test_boot_time (line 492) | def test_boot_time(self):
  class NetBSDTestCase (line 505) | class NetBSDTestCase(PsutilTestCase):
    method parse_meminfo (line 507) | def parse_meminfo(look_for):
    method test_vmem_total (line 516) | def test_vmem_total(self):
    method test_vmem_free (line 519) | def test_vmem_free(self):
    method test_vmem_buffers (line 525) | def test_vmem_buffers(self):
    method test_vmem_shared (line 534) | def test_vmem_shared(self):
    method test_vmem_cached (line 543) | def test_vmem_cached(self):
    method test_swapmem_total (line 551) | def test_swapmem_total(self):
    method test_swapmem_free (line 557) | def test_swapmem_free(self):
    method test_swapmem_used (line 563) | def test_swapmem_used(self):
    method test_cpu_stats_interrupts (line 569) | def test_cpu_stats_interrupts(self):
    method test_cpu_stats_ctx_switches (line 579) | def test_cpu_stats_ctx_switches(self):

FILE: tests/test_connections.py
  function this_proc_net_connections (line 50) | def this_proc_net_connections(kind):
  class ConnectionTestCase (line 58) | class ConnectionTestCase(PsutilTestCase):
    method setUp (line 59) | def setUp(self):
    method tearDown (line 62) | def tearDown(self):
    method compare_procsys_connections (line 66) | def compare_procsys_connections(self, pid, proc_cons, kind='all'):
  class TestBasicOperations (line 87) | class TestBasicOperations(ConnectionTestCase):
    method test_system (line 89) | def test_system(self):
    method test_process (line 94) | def test_process(self):
    method test_invalid_kind (line 99) | def test_invalid_kind(self):
  class TestUnconnectedSockets (line 107) | class TestUnconnectedSockets(ConnectionTestCase):
    method get_conn_from_sock (line 110) | def get_conn_from_sock(self, sock):
    method check_socket (line 123) | def check_socket(self, sock):
    method test_tcp_v4 (line 153) | def test_tcp_v4(self):
    method test_tcp_v6 (line 161) | def test_tcp_v6(self):
    method test_udp_v4 (line 168) | def test_udp_v4(self):
    method test_udp_v6 (line 176) | def test_udp_v6(self):
    method test_unix_tcp (line 184) | def test_unix_tcp(self):
    method test_unix_udp (line 192) | def test_unix_udp(self):
  class TestConnectedSocket (line 201) | class TestConnectedSocket(ConnectionTestCase):
    method test_tcp (line 209) | def test_tcp(self):
    method test_unix (line 232) | def test_unix(self):
  class TestFilters (line 259) | class TestFilters(ConnectionTestCase):
    method test_filters (line 260) | def test_filters(self):
    method test_combos (line 292) | def test_combos(self):
    method test_count (line 430) | def test_count(self):
  class TestSystemWideConnections (line 490) | class TestSystemWideConnections(ConnectionTestCase):
    method test_it (line 493) | def test_it(self):
    method test_multi_sockets_procs (line 514) | def test_multi_sockets_procs(self):
  class TestMisc (line 555) | class TestMisc(PsutilTestCase):
    method test_net_connection_constants (line 556) | def test_net_connection_constants(self):

FILE: tests/test_contracts.py
  class TestAvailConstantsAPIs (line 52) | class TestAvailConstantsAPIs(PsutilTestCase):
    method check_constants (line 54) | def check_constants(self, names, are_avail):
    method test_PROCFS_PATH (line 65) | def test_PROCFS_PATH(self):
    method test_proc_status (line 68) | def test_proc_status(self):
    method test_proc_status_strenum (line 88) | def test_proc_status_strenum(self):
    method test_conn_status (line 110) | def test_conn_status(self):
    method test_conn_status_strenum (line 133) | def test_conn_status_strenum(self):
    method test_nic_duplex (line 153) | def test_nic_duplex(self):
    method test_battery_time (line 158) | def test_battery_time(self):
    method test_proc_ioprio_class_linux (line 163) | def test_proc_ioprio_class_linux(self):
    method test_proc_ioprio_value_windows (line 178) | def test_proc_ioprio_value_windows(self):
    method test_proc_priority_windows (line 191) | def test_proc_priority_windows(self):
    method test_rlimit (line 212) | def test_rlimit(self):
    method test_enum_containers (line 242) | def test_enum_containers(self):
  class TestAvailSystemAPIs (line 251) | class TestAvailSystemAPIs(PsutilTestCase):
    method test_win_service_iter (line 252) | def test_win_service_iter(self):
    method test_win_service_get (line 255) | def test_win_service_get(self):
    method test_cpu_freq (line 261) | def test_cpu_freq(self):
    method test_sensors_temperatures (line 266) | def test_sensors_temperatures(self):
    method test_sensors_fans (line 269) | def test_sensors_fans(self):
    method test_battery (line 272) | def test_battery(self):
    method test_heap_info (line 277) | def test_heap_info(self):
    method test_heap_trim (line 284) | def test_heap_trim(self):
  class TestAvailProcessAPIs (line 292) | class TestAvailProcessAPIs(PsutilTestCase):
    method test_environ (line 293) | def test_environ(self):
    method test_uids (line 305) | def test_uids(self):
    method test_gids (line 308) | def test_gids(self):
    method test_terminal (line 311) | def test_terminal(self):
    method test_ionice (line 314) | def test_ionice(self):
    method test_rlimit (line 321) | def test_rlimit(self):
    method test_io_counters (line 324) | def test_io_counters(self):
    method test_num_fds (line 328) | def test_num_fds(self):
    method test_num_handles (line 331) | def test_num_handles(self):
    method test_cpu_affinity (line 334) | def test_cpu_affinity(self):
    method test_cpu_num (line 339) | def test_cpu_num(self):
    method test_memory_maps (line 344) | def test_memory_maps(self):
    method test_memory_footprint (line 348) | def test_memory_footprint(self):
  class TestSystemAPITypes (line 358) | class TestSystemAPITypes(PsutilTestCase):
    method setUpClass (line 364) | def setUpClass(cls):
    method assert_ntuple_of_nums (line 367) | def assert_ntuple_of_nums(self, nt, type_=float, gezero=True):
    method test_cpu_times (line 374) | def test_cpu_times(self):
    method test_cpu_percent (line 379) | def test_cpu_percent(self):
    method test_cpu_times_percent (line 383) | def test_cpu_times_percent(self):
    method test_cpu_count (line 387) | def test_cpu_count(self):
    method test_cpu_freq (line 391) | def test_cpu_freq(self):
    method test_disk_io_counters (line 396) | def test_disk_io_counters(self):
    method test_disk_partitions (line 402) | def test_disk_partitions(self):
    method test_net_connections (line 411) | def test_net_connections(self):
    method test_net_if_addrs (line 418) | def test_net_if_addrs(self):
    method test_net_if_stats (line 428) | def test_net_if_stats(self):
    method test_net_io_counters (line 438) | def test_net_io_counters(self):
    method test_sensors_fans (line 444) | def test_sensors_fans(self):
    method test_sensors_temperatures (line 453) | def test_sensors_temperatures(self):
    method test_boot_time (line 463) | def test_boot_time(self):
    method test_users (line 467) | def test_users(self):

FILE: tests/test_heap.py
  function malloc (line 72) | def malloc(size):
  function free (line 84) | def free(ptr):
  function GetProcessHeap (line 104) | def GetProcessHeap():
  function HeapAlloc (line 112) | def HeapAlloc(heap, size):
  function HeapFree (line 120) | def HeapFree(heap, addr):
  function VirtualAllocEx (line 128) | def VirtualAllocEx(size):
  function VirtualFreeEx (line 137) | def VirtualFreeEx(addr):
  function HeapCreate (line 144) | def HeapCreate(initial_size, max_size):
  function HeapDestroy (line 156) | def HeapDestroy(heap):
  function trim_memory (line 168) | def trim_memory():
  function assert_within_percent (line 173) | def assert_within_percent(actual, expected, percent):
  class HeapTestCase (line 185) | class HeapTestCase(PsutilTestCase):
    method setUp (line 186) | def setUp(self):
    method tearDownClass (line 190) | def tearDownClass(cls):
  class TestHeap (line 194) | class TestHeap(HeapTestCase):
    method test_heap_used (line 199) | def test_heap_used(self):
    method test_mmap_used (line 232) | def test_mmap_used(self):
  class TestHeapWindows (line 274) | class TestHeapWindows(HeapTestCase):
    method test_heap_used (line 277) | def test_heap_used(self):
    method test_mmap_used (line 296) | def test_mmap_used(self):
    method test_heap_count (line 316) | def test_heap_count(self):

FILE: tests/test_linux.py
  class LinuxTestCase (line 62) | class LinuxTestCase(PsutilTestCase):
  function get_ipv4_address (line 71) | def get_ipv4_address(ifname):
  function get_ipv4_netmask (line 83) | def get_ipv4_netmask(ifname):
  function get_ipv4_broadcast (line 95) | def get_ipv4_broadcast(ifname):
  function get_ipv6_addresses (line 107) | def get_ipv6_addresses(ifname):
  function get_mac_address (line 129) | def get_mac_address(ifname):
  function free_swap (line 140) | def free_swap():
  function free_physmem (line 154) | def free_physmem():
  function vmstat (line 174) | def vmstat(stat):
  function get_free_version_info (line 183) | def get_free_version_info():
  function mock_open_content (line 191) | def mock_open_content(pairs):
  function mock_open_exception (line 212) | def mock_open_exception(for_path, exc):
  class TestSystemVirtualMemoryAgainstFree (line 232) | class TestSystemVirtualMemoryAgainstFree(LinuxTestCase):
    method test_total (line 233) | def test_total(self):
    method test_used (line 239) | def test_used(self):
    method test_free (line 253) | def test_free(self):
    method test_shared (line 259) | def test_shared(self):
    method test_available (line 270) | def test_available(self):
  class TestSystemVirtualMemoryAgainstVmstat (line 282) | class TestSystemVirtualMemoryAgainstVmstat(LinuxTestCase):
    method test_total (line 283) | def test_total(self):
    method test_used (line 289) | def test_used(self):
    method test_free (line 303) | def test_free(self):
    method test_buffers (line 309) | def test_buffers(self):
    method test_active (line 315) | def test_active(self):
    method test_inactive (line 321) | def test_inactive(self):
  class TestSystemVirtualMemoryMocks (line 327) | class TestSystemVirtualMemoryMocks(LinuxTestCase):
    method test_warnings_on_misses (line 328) | def test_warnings_on_misses(self):
    method test_avail_old_percent (line 365) | def test_avail_old_percent(self):
    method test_avail_old_comes_from_kernel (line 380) | def test_avail_old_comes_from_kernel(self):
    method test_avail_old_missing_fields (line 408) | def test_avail_old_missing_fields(self):
    method test_avail_old_missing_zoneinfo (line 433) | def test_avail_old_missing_zoneinfo(self):
    method test_virtual_memory_mocked (line 461) | def test_virtual_memory_mocked(self):
  class TestSystemSwapMemory (line 533) | class TestSystemSwapMemory(LinuxTestCase):
    method meminfo_has_swap_info (line 535) | def meminfo_has_swap_info():
    method test_total (line 541) | def test_total(self):
    method test_used (line 547) | def test_used(self):
    method test_free (line 553) | def test_free(self):
    method test_missing_sin_sout (line 558) | def test_missing_sin_sout(self):
    method test_no_vmstat_mocked (line 573) | def test_no_vmstat_mocked(self):
    method test_meminfo_against_sysinfo (line 590) | def test_meminfo_against_sysinfo(self):
    method test_emulate_meminfo_has_no_metrics (line 607) | def test_emulate_meminfo_has_no_metrics(self):
  class TestSystemCPUCountLogical (line 621) | class TestSystemCPUCountLogical(LinuxTestCase):
    method test_against_sysdev_cpu_online (line 626) | def test_against_sysdev_cpu_online(self):
    method test_against_sysdev_cpu_num (line 637) | def test_against_sysdev_cpu_num(self):
    method test_against_nproc (line 645) | def test_against_nproc(self):
    method test_against_lscpu (line 652) | def test_against_lscpu(self):
    method test_emulate_fallbacks (line 657) | def test_emulate_fallbacks(self):
  class TestSystemCPUCountCores (line 694) | class TestSystemCPUCountCores(LinuxTestCase):
    method test_against_lscpu (line 698) | def test_against_lscpu(self):
    method test_method_2 (line 710) | def test_method_2(self):
    method test_emulate_none (line 718) | def test_emulate_none(self):
  class TestSystemCPUFrequency (line 726) | class TestSystemCPUFrequency(LinuxTestCase):
    method test_emulate_use_second_file (line 731) | def test_emulate_use_second_file(self):
    method test_emulate_use_cpuinfo (line 750) | def test_emulate_use_cpuinfo(self):
    method test_emulate_data (line 775) | def test_emulate_data(self):
    method test_emulate_multi_cpu (line 807) | def test_emulate_multi_cpu(self):
    method test_emulate_no_scaling_cur_freq_file (line 858) | def test_emulate_no_scaling_cur_freq_file(self):
  class TestSystemCPUStats (line 880) | class TestSystemCPUStats(LinuxTestCase):
    method test_interrupts (line 888) | def test_interrupts(self):
  class TestLoadAvg (line 894) | class TestLoadAvg(LinuxTestCase):
    method test_getloadavg (line 895) | def test_getloadavg(self):
  class TestSystemNetIfAddrs (line 910) | class TestSystemNetIfAddrs(LinuxTestCase):
    method test_ips (line 911) | def test_ips(self):
    method test_against_ip_addr_v4 (line 937) | def test_against_ip_addr_v4(self):
    method test_against_ip_addr_v6 (line 967) | def test_against_ip_addr_v6(self):
  class TestSystemNetIfStats (line 1011) | class TestSystemNetIfStats(LinuxTestCase):
    method test_against_ifconfig (line 1015) | def test_against_ifconfig(self):
    method test_mtu (line 1027) | def test_mtu(self):
    method test_flags (line 1035) | def test_flags(self):
  class TestSystemNetIOCounters (line 1065) | class TestSystemNetIOCounters(LinuxTestCase):
    method test_against_ifconfig (line 1070) | def test_against_ifconfig(self):
  class TestSystemNetConnections (line 1116) | class TestSystemNetConnections(LinuxTestCase):
    method test_emulate_ipv6_unsupported (line 1119) | def test_emulate_ipv6_unsupported(self, supports_ipv6, inet_ntop):
    method test_emulate_unix (line 1128) | def test_emulate_unix(self):
  class TestSystemDiskPartitions (line 1145) | class TestSystemDiskPartitions(LinuxTestCase):
    method test_against_df (line 1150) | def test_against_df(self):
    method test_zfs_fs (line 1171) | def test_zfs_fs(self):
    method test_emulate_realpath_fail (line 1195) | def test_emulate_realpath_fail(self):
  class TestSystemDiskIoCounters (line 1208) | class TestSystemDiskIoCounters(LinuxTestCase):
    method test_emulate_kernel_2_4 (line 1209) | def test_emulate_kernel_2_4(self):
    method test_emulate_kernel_2_6_full (line 1228) | def test_emulate_kernel_2_6_full(self):
    method test_emulate_kernel_2_6_limited (line 1248) | def test_emulate_kernel_2_6_limited(self):
    method test_emulate_include_partitions (line 1270) | def test_emulate_include_partitions(self):
    method test_emulate_exclude_partitions (line 1289) | def test_emulate_exclude_partitions(self):
    method test_emulate_use_sysfs (line 1321) | def test_emulate_use_sysfs(self):
    method test_emulate_not_impl (line 1332) | def test_emulate_not_impl(self):
  class TestRootFsDeviceFinder (line 1343) | class TestRootFsDeviceFinder(LinuxTestCase):
    method setUp (line 1344) | def setUp(self):
    method test_call_methods (line 1349) | def test_call_methods(self):
    method test_comparisons (line 1364) | def test_comparisons(self):
    method test_against_findmnt (line 1387) | def test_against_findmnt(self):
    method test_disk_partitions_mocked (line 1392) | def test_disk_partitions_mocked(self):
  class TestMisc (line 1411) | class TestMisc(LinuxTestCase):
    method test_boot_time (line 1412) | def test_boot_time(self):
    method test_no_procfs_on_import (line 1417) | def test_no_procfs_on_import(self):
    method test_cpu_steal_decrease (line 1482) | def test_cpu_steal_decrease(self):
    method test_boot_time_mocked (line 1521) | def test_boot_time_mocked(self):
    method test_users (line 1527) | def test_users(self):
    method test_procfs_path (line 1533) | def test_procfs_path(self):
    method test_issue_687 (line 1561) | def test_issue_687(self):
    method test_pid_exists_no_proc_status (line 1579) | def test_pid_exists_no_proc_status(self):
  class TestSensorsBattery (line 1594) | class TestSensorsBattery(LinuxTestCase):
    method test_percent (line 1598) | def test_percent(self):
    method test_emulate_power_plugged (line 1604) | def test_emulate_power_plugged(self):
    method test_emulate_power_plugged_2 (line 1621) | def test_emulate_power_plugged_2(self):
    method test_emulate_power_not_plugged (line 1637) | def test_emulate_power_not_plugged(self):
    method test_emulate_power_not_plugged_2 (line 1650) | def test_emulate_power_not_plugged_2(self):
    method test_emulate_power_undetermined (line 1666) | def test_emulate_power_undetermined(self):
    method test_emulate_energy_full_0 (line 1685) | def test_emulate_energy_full_0(self):
    method test_emulate_energy_full_not_avail (line 1693) | def test_emulate_energy_full_not_avail(self):
    method test_percent_against_capacity (line 1713) | def test_percent_against_capacity(self):
    method test_emulate_no_power (line 1724) | def test_emulate_no_power(self):
  class TestSensorsBatteryEmulated (line 1739) | class TestSensorsBatteryEmulated(LinuxTestCase):
    method test_it (line 1740) | def test_it(self):
  class TestSensorsTemperatures (line 1759) | class TestSensorsTemperatures(LinuxTestCase):
    method test_emulate_class_hwmon (line 1760) | def test_emulate_class_hwmon(self):
    method test_emulate_class_thermal (line 1787) | def test_emulate_class_thermal(self):
  class TestSensorsFans (line 1825) | class TestSensorsFans(LinuxTestCase):
    method test_emulate_data (line 1826) | def test_emulate_data(self):
  class TestProcess (line 1852) | class TestProcess(LinuxTestCase):
    method test_parse_smaps_vs_memory_maps (line 1854) | def test_parse_smaps_vs_memory_maps(self):
    method test_parse_smaps_mocked (line 1865) | def test_parse_smaps_mocked(self):
    method test_open_files_mode (line 1898) | def test_open_files_mode(self):
    method test_open_files_file_gone (line 1931) | def test_open_files_file_gone(self):
    method test_open_files_fd_gone (line 1954) | def test_open_files_fd_gone(self):
    method test_open_files_enametoolong (line 1969) | def test_open_files_enametoolong(self):
    method test_terminal_mocked (line 1988) | def test_terminal_mocked(self):
    method test_cmdline_mocked (line 1995) | def test_cmdline_mocked(self):
    method test_cmdline_spaces_mocked (line 2011) | def test_cmdline_spaces_mocked(self):
    method test_cmdline_mixed_separators (line 2027) | def test_cmdline_mixed_separators(self):
    method test_readlink_path_deleted_mocked (line 2037) | def test_readlink_path_deleted_mocked(self):
    method test_threads_mocked (line 2044) | def test_threads_mocked(self):
    method test_exe_mocked (line 2071) | def test_exe_mocked(self):
    method test_cwd_mocked (line 2083) | def test_cwd_mocked(self):
    method test_issue_1014 (line 2092) | def test_issue_1014(self):
    method test_issue_2418 (line 2103) | def test_issue_2418(self):
    method test_rlimit_zombie (line 2113) | def test_rlimit_zombie(self):
    method test_stat_file_parsing (line 2132) | def test_stat_file_parsing(self):
    method test_status_file_parsing (line 2192) | def test_status_file_parsing(self):
    method test_net_connections_enametoolong (line 2216) | def test_net_connections_enametoolong(self):
    method test_create_time_monotonic (line 2229) | def test_create_time_monotonic(self):
    method test_memory_info_ex (line 2234) | def test_memory_info_ex(self):
  class TestProcessAgainstStatus (line 2239) | class TestProcessAgainstStatus(LinuxTestCase):
    method setUpClass (line 2248) | def setUpClass(cls):
    method read_status_file (line 2251) | def read_status_file(self, linestart):
    method test_name (line 2265) | def test_name(self):
    method test_status (line 2269) | def test_status(self):
    method test_ppid (line 2275) | def test_ppid(self):
    method test_num_threads (line 2279) | def test_num_threads(self):
    method test_uids (line 2283) | def test_uids(self):
    method test_gids (line 2288) | def test_gids(self):
    method test_num_ctx_switches (line 2294) | def test_num_ctx_switches(self):
    method test_cpu_affinity (line 2300) | def test_cpu_affinity(self):
    method test_cpu_affinity_eligible_cpus (line 2306) | def test_cpu_affinity_eligible_cpus(self):
  class TestUtils (line 2321) | class TestUtils(LinuxTestCase):
    method test_readlink (line 2322) | def test_readlink(self):

FILE: tests/test_memleaks.py
  class TestProcessObjectLeaks (line 62) | class TestProcessObjectLeaks(MemoryLeakTestCase):
    method test_coverage (line 67) | def test_coverage(self):
    method test_name (line 71) | def test_name(self):
    method test_cmdline (line 74) | def test_cmdline(self):
    method test_exe (line 79) | def test_exe(self):
    method test_ppid (line 82) | def test_ppid(self):
    method test_uids (line 86) | def test_uids(self):
    method test_gids (line 90) | def test_gids(self):
    method test_status (line 93) | def test_status(self):
    method test_nice (line 96) | def test_nice(self):
    method test_nice_set (line 99) | def test_nice_set(self):
    method test_ionice (line 104) | def test_ionice(self):
    method test_ionice_set (line 108) | def test_ionice_set(self):
    method test_ionice_set_badarg (line 117) | def test_ionice_set_badarg(self):
    method test_io_counters (line 122) | def test_io_counters(self):
    method test_username (line 126) | def test_username(self):
    method test_create_time (line 131) | def test_create_time(self):
    method test_num_threads (line 135) | def test_num_threads(self):
    method test_num_handles (line 139) | def test_num_handles(self):
    method test_num_fds (line 143) | def test_num_fds(self):
    method test_num_ctx_switches (line 146) | def test_num_ctx_switches(self):
    method test_threads (line 150) | def test_threads(self):
    method test_cpu_times (line 154) | def test_cpu_times(self):
    method test_cpu_num (line 158) | def test_cpu_num(self):
    method test_memory_info (line 161) | def test_memory_info(self):
    method test_memory_info_ex (line 164) | def test_memory_info_ex(self):
    method test_memory_footprint (line 168) | def test_memory_footprint(self):
    method test_terminal (line 172) | def test_terminal(self):
    method test_resume (line 175) | def test_resume(self):
    method test_cwd (line 179) | def test_cwd(self):
    method test_cpu_affinity (line 183) | def test_cpu_affinity(self):
    method test_cpu_affinity_set (line 187) | def test_cpu_affinity_set(self):
    method test_cpu_affinity_set_badarg (line 192) | def test_cpu_affinity_set_badarg(self):
    method test_open_files (line 197) | def test_open_files(self):
    method test_memory_maps (line 204) | def test_memory_maps(self):
    method test_page_faults (line 207) | def test_page_faults(self):
    method test_rlimit (line 212) | def test_rlimit(self):
    method test_rlimit_set (line 217) | def test_rlimit_set(self):
    method test_rlimit_set_badarg (line 223) | def test_rlimit_set_badarg(self):
    method test_net_connections (line 231) | def test_net_connections(self):
    method test_environ (line 241) | def test_environ(self):
    method test_proc_oneshot (line 245) | def test_proc_oneshot(self):
  class TestTerminatedProcessLeaks (line 249) | class TestTerminatedProcessLeaks(TestProcessObjectLeaks):
    method setUpClass (line 257) | def setUpClass(cls):
    method tearDownClass (line 265) | def tearDownClass(cls):
    method call (line 269) | def call(self, fun):
    method test_cpu_affinity_set_badarg (line 275) | def test_cpu_affinity_set_badarg(self):
    method test_kill (line 280) | def test_kill(self):
    method test_terminate (line 283) | def test_terminate(self):
    method test_suspend (line 286) | def test_suspend(self):
    method test_resume (line 289) | def test_resume(self):
    method test_wait (line 292) | def test_wait(self):
    method test_proc_oneshot (line 295) | def test_proc_oneshot(self):
  class TestProcessDualImplementation (line 307) | class TestProcessDualImplementation(MemoryLeakTestCase):
    method test_cmdline_peb_true (line 308) | def test_cmdline_peb_true(self):
    method test_cmdline_peb_false (line 311) | def test_cmdline_peb_false(self):
  class TestModuleFunctionsLeaks (line 320) | class TestModuleFunctionsLeaks(MemoryLeakTestCase):
    method test_coverage (line 323) | def test_coverage(self):
    method test_cpu_count (line 329) | def test_cpu_count(self):  # logical
    method test_cpu_count_cores (line 332) | def test_cpu_count_cores(self):
    method test_cpu_times (line 335) | def test_cpu_times(self):
    method test_per_cpu_times (line 338) | def test_per_cpu_times(self):
    method test_cpu_stats (line 341) | def test_cpu_stats(self):
    method test_cpu_freq (line 345) | def test_cpu_freq(self):
    method test_getloadavg (line 350) | def test_getloadavg(self):
    method test_virtual_memory (line 356) | def test_virtual_memory(self):
    method test_swap_memory (line 361) | def test_swap_memory(self):
    method test_pid_exists (line 364) | def test_pid_exists(self):
    method test_disk_usage (line 370) | def test_disk_usage(self):
    method test_disk_partitions (line 374) | def test_disk_partitions(self):
    method test_disk_io_counters (line 381) | def test_disk_io_counters(self):
    method test_pids (line 386) | def test_pids(self):
    method test_net_io_counters (line 392) | def test_net_io_counters(self):
    method test_net_connections (line 396) | def test_net_connections(self):
    method test_net_if_addrs (line 405) | def test_net_if_addrs(self):
    method test_net_if_stats (line 418) | def test_net_if_stats(self):
    method test_sensors_battery (line 424) | def test_sensors_battery(self):
    method test_sensors_temperatures (line 429) | def test_sensors_temperatures(self):
    method test_sensors_fans (line 434) | def test_sensors_fans(self):
    method test_boot_time (line 440) | def test_boot_time(self):
    method test_users (line 443) | def test_users(self):
    method test_set_debug (line 452) | def test_set_debug(self):
    method test_heap_info (line 456) | def test_heap_info(self):
    method test_heap_trim (line 460) | def test_heap_trim(self):
    method test_win_service_iter (line 467) | def test_win_service_iter(self):
    method test_win_service_get (line 470) | def test_win_service_get(self):
    method test_win_service_get_config (line 473) | def test_win_service_get_config(self):
    method test_win_service_get_status (line 477) | def test_win_service_get_status(self):
    method test_win_service_get_description (line 481) | def test_win_service_get_description(self):

FILE: tests/test_misc.py
  class TestSpecialMethods (line 42) | class TestSpecialMethods(PsutilTestCase):
    method test_check_pid_range (line 43) | def test_check_pid_range(self):
    method test_process__repr__ (line 49) | def test_process__repr__(self, func=repr):
    method test_process__str__ (line 93) | def test_process__str__(self):
    method test_error__repr__ (line 96) | def test_error__repr__(self):
    method test_error__str__ (line 99) | def test_error__str__(self):
    method test_no_such_process__repr__ (line 102) | def test_no_such_process__repr__(self):
    method test_no_such_process__str__ (line 112) | def test_no_such_process__str__(self):
    method test_zombie_process__repr__ (line 122) | def test_zombie_process__repr__(self):
    method test_zombie_process__str__ (line 134) | def test_zombie_process__str__(self):
    method test_access_denied__repr__ (line 144) | def test_access_denied__repr__(self):
    method test_access_denied__str__ (line 151) | def test_access_denied__str__(self):
    method test_timeout_expired__repr__ (line 158) | def test_timeout_expired__repr__(self):
    method test_timeout_expired__str__ (line 170) | def test_timeout_expired__str__(self):
    method test_process__eq__ (line 177) | def test_process__eq__(self):
    method test_process__hash__ (line 185) | def test_process__hash__(self):
  class TestMisc (line 195) | class TestMisc(PsutilTestCase):
    method test__all__ (line 196) | def test__all__(self):
    method test_version (line 232) | def test_version(self):
    method test_process_as_dict_no_new_names (line 238) | def test_process_as_dict_no_new_names(self):
    method test_serialization (line 244) | def test_serialization(self):
    method test_ad_on_process_creation (line 322) | def test_ad_on_process_creation(self):
    method test_sanity_version_check (line 351) | def test_sanity_version_check(self):
  class TestCommonModule (line 366) | class TestCommonModule(PsutilTestCase):
    method test_memoize_when_activated (line 367) | def test_memoize_when_activated(self):
    method test_parse_environ_block (line 393) | def test_parse_environ_block(self):
    method test_supports_ipv6 (line 414) | def test_supports_ipv6(self):
    method test_isfile_strict (line 446) | def test_isfile_strict(self):
    method test_debug (line 460) | def test_debug(self):
    method test_cat_bcat (line 488) | def test_cat_bcat(self):
  class TestWrapNumbers (line 510) | class TestWrapNumbers(PsutilTestCase):
    method setUp (line 511) | def setUp(self):
    method test_first_call (line 516) | def test_first_call(self):
    method test_input_hasnt_changed (line 520) | def test_input_hasnt_changed(self):
    method test_increase_but_no_wrap (line 525) | def test_increase_but_no_wrap(self):
    method test_wrap (line 535) | def test_wrap(self):
    method test_changing_keys (line 564) | def test_changing_keys(self):
    method test_changing_keys_w_wrap (line 575) | def test_changing_keys_w_wrap(self):
    method test_real_data (line 602) | def test_real_data(self):
    method test_cache_first_call (line 623) | def test_cache_first_call(self):
    method test_cache_call_twice (line 631) | def test_cache_call_twice(self):
    method test_cache_wrap (line 643) | def test_cache_wrap(self):
    method test_cache_changing_keys (line 693) | def test_cache_changing_keys(self):
    method test_cache_clear (line 705) | def test_cache_clear(self):
    method test_cache_clear_public_apis (line 715) | def test_cache_clear_public_apis(self):

FILE: tests/test_osx.py
  function sysctl (line 29) | def sysctl(cmdline):
  function vm_stat (line 41) | def vm_stat(field):
  class MacosTestCase (line 56) | class MacosTestCase(PsutilTestCase):
  class TestProcess (line 60) | class TestProcess(MacosTestCase):
    method setUpClass (line 62) | def setUpClass(cls):
    method tearDownClass (line 66) | def tearDownClass(cls):
    method test_process_create_time (line 69) | def test_process_create_time(self):
  class TestSystemAPIs (line 81) | class TestSystemAPIs(MacosTestCase):
    method test_disks (line 86) | def test_disks(self):
    method test_cpu_count_logical (line 112) | def test_cpu_count_logical(self):
    method test_cpu_count_cores (line 116) | def test_cpu_count_cores(self):
    method test_cpu_freq (line 124) | def test_cpu_freq(self):
    method test_vmem_total (line 132) | def test_vmem_total(self):
    method test_vmem_free (line 141) | def test_vmem_free(self):
    method test_vmem_active (line 151) | def test_vmem_active(self):
    method test_vmem_inactive (line 159) | def test_vmem_inactive(self):
    method test_vmem_wired (line 165) | def test_vmem_wired(self):
    method test_swapmem_sin (line 173) | def test_swapmem_sin(self):
    method test_swapmem_sout (line 179) | def test_swapmem_sout(self):
    method test_net_if_stats (line 186) | def test_net_if_stats(self):
    method test_sensors_battery (line 199) | def test_sensors_battery(self):
    method test_boot_time (line 210) | def test_boot_time(self):

FILE: tests/test_posix.py
  function ps (line 43) | def ps(fmt, pid=None):
  function ps_name (line 98) | def ps_name(pid):
  function ps_args (line 106) | def ps_args(pid):
  function ps_rss (line 116) | def ps_rss(pid):
  function ps_vsz (line 123) | def ps_vsz(pid):
  function df (line 130) | def df(device):
  class PosixTestCase (line 147) | class PosixTestCase(PsutilTestCase):
  class TestProcess (line 151) | class TestProcess(PosixTestCase):
    method setUpClass (line 155) | def setUpClass(cls):
    method tearDownClass (line 161) | def tearDownClass(cls):
    method test_ppid (line 164) | def test_ppid(self):
    method test_uid (line 169) | def test_uid(self):
    method test_gid (line 174) | def test_gid(self):
    method test_username (line 179) | def test_username(self):
    method test_username_no_resolution (line 184) | def test_username_no_resolution(self):
    method test_rss_memory (line 195) | def test_rss_memory(self):
    method test_vsz_memory (line 205) | def test_vsz_memory(self):
    method test_name (line 213) | def test_name(self):
    method test_name_long (line 227) | def test_name_long(self):
    method test_name_long_cmdline_ad_exc (line 240) | def test_name_long_cmdline_ad_exc(self):
    method test_name_long_cmdline_nsp_exc (line 253) | def test_name_long_cmdline_nsp_exc(self):
    method test_create_time (line 267) | def test_create_time(self):
    method test_exe (line 281) | def test_exe(self):
    method test_cmdline (line 302) | def test_cmdline(self):
    method test_nice (line 317) | def test_nice(self):
    method test_num_ctx_switches (line 323) | def test_num_ctx_switches(self):
    method test_cpu_times (line 338) | def test_cpu_times(self):
    method test_page_faults (line 345) | def test_page_faults(self):
    method test_page_faults_minor_increase (line 353) | def test_page_faults_minor_increase(self):
    method test_memory_peak_rss (line 364) | def test_memory_peak_rss(self):
  class TestSystemAPIs (line 378) | class TestSystemAPIs(PosixTestCase):
    method test_pids (line 382) | def test_pids(self):
    method test_nic_names (line 404) | def test_nic_names(self):
    method test_users (line 417) | def test_users(self):
    method test_users_started (line 448) | def test_users_started(self):
    method test_pid_exists_let_raise (line 484) | def test_pid_exists_let_raise(self):
    method test_disk_usage (line 498) | def test_disk_usage(self):
  class TestMisc (line 523) | class TestMisc(PosixTestCase):
    method test_getpagesize (line 524) | def test_getpagesize(self):

FILE: tests/test_process.py
  class TestProcess (line 77) | class TestProcess(PsutilTestCase):
    method test_pid (line 80) | def test_pid(self):
    method test_kill (line 86) | def test_kill(self):
    method test_terminate (line 96) | def test_terminate(self):
    method test_send_signal (line 106) | def test_send_signal(self):
    method test_send_signal_mocked (line 118) | def test_send_signal_mocked(self):
    method test_cpu_percent (line 130) | def test_cpu_percent(self):
    method test_cpu_percent_numcpus_none (line 141) | def test_cpu_percent_numcpus_none(self):
    method test_cpu_times (line 147) | def test_cpu_times(self):
    method test_cpu_num (line 160) | def test_cpu_num(self):
    method test_create_time (line 168) | def test_create_time(self):
    method test_terminal (line 177) | def test_terminal(self):
    method test_io_counters (line 190) | def test_io_counters(self):
    method test_ionice_linux (line 230) | def test_ionice_linux(self):
    method test_ionice_win (line 277) | def test_ionice_win(self):
    method test_rlimit_get (line 304) | def test_rlimit_get(self):
    method test_rlimit_set (line 328) | def test_rlimit_set(self):
    method test_rlimit (line 341) | def test_rlimit(self):
    method test_rlimit_infinity (line 360) | def test_rlimit_infinity(self):
    method test_rlimit_infinity_value (line 375) | def test_rlimit_infinity_value(self):
    method test_num_threads (line 387) | def test_num_threads(self):
    method test_num_handles (line 405) | def test_num_handles(self):
    method test_threads (line 411) | def test_threads(self):
    method test_threads_2 (line 433) | def test_threads_2(self):
    method test_memory_info (line 450) | def test_memory_info(self):
    method test_memory_info_ex (line 472) | def test_memory_info_ex(self):
    method test_memory_info_ex_fields_order (line 482) | def test_memory_info_ex_fields_order(self):
    method test_memory_footprint (line 523) | def test_memory_footprint(self):
    method test_memory_full_info (line 528) | def test_memory_full_info(self):
    method test_memory_maps (line 545) | def test_memory_maps(self):
    method test_memory_maps_lists_lib (line 594) | def test_memory_maps_lists_lib(self):
    method test_memory_percent (line 605) | def test_memory_percent(self):
    method test_page_faults (line 613) | def test_page_faults(self):
    method test_is_running (line 619) | def test_is_running(self):
    method test_exe (line 628) | def test_exe(self):
    method test_cmdline (line 655) | def test_cmdline(self):
    method test_long_cmdline (line 682) | def test_long_cmdline(self):
    method test_name (line 708) | def test_name(self):
    method test_long_name (line 717) | def test_long_name(self):
    method test_uids (line 744) | def test_uids(self):
    method test_gids (line 757) | def test_gids(self):
    method test_nice (line 769) | def test_nice(self):
    method test_status (line 835) | def test_status(self):
    method test_username (line 839) | def test_username(self):
    method test_cwd (line 856) | def test_cwd(self):
    method test_cwd_2 (line 860) | def test_cwd_2(self):
    method test_cpu_affinity (line 873) | def test_cpu_affinity(self):
    method test_cpu_affinity_errs (line 912) | def test_cpu_affinity_errs(self):
    method test_cpu_affinity_all_combinations (line 925) | def test_cpu_affinity_all_combinations(self):
    method test_open_files (line 948) | def test_open_files(self):
    method test_open_files_2 (line 987) | def test_open_files_2(self):
    method test_num_fds (line 1015) | def test_num_fds(self):
    method test_num_ctx_switches (line 1029) | def test_num_ctx_switches(self):
    method test_ppid (line 1041) | def test_ppid(self):
    method test_parent (line 1048) | def test_parent(self):
    method test_parent_mocked_ctime (line 1055) | def test_parent_mocked_ctime(self):
    method test_parent_multi (line 1067) | def test_parent_multi(self):
    method test_parents (line 1074) | def test_parents(self):
    method test_children (line 1082) | def test_children(self):
    method test_children_mocked_ctime (line 1097) | def test_children_mocked_ctime(self):
    method test_children_recursive (line 1121) | def test_children_recursive(self):
    method test_children_duplicates (line 1134) | def test_children_duplicates(self):
    method test_parents_and_children (line 1154) | def test_parents_and_children(self):
    method test_suspend_resume (line 1167) | def test_suspend_resume(self):
    method test_invalid_pid (line 1177) | def test_invalid_pid(self):
    method test_as_dict (line 1183) | def test_as_dict(self):
    method test_oneshot (line 1235) | def test_oneshot(self):
    method test_oneshot_twice (line 1248) | def test_oneshot_twice(self):
    method test_oneshot_cache (line 1268) | def test_oneshot_cache(self):
    method test_halfway_terminated_process (line 1283) | def test_halfway_terminated_process(self):
    method test_zombie_process (line 1322) | def test_zombie_process(self):
    method test_zombie_process_is_running_w_exc (line 1333) | def test_zombie_process_is_running_w_exc(self):
    method test_zombie_process_status_w_exc (line 1344) | def test_zombie_process_status_w_exc(self):
    method test_reused_pid (line 1355) | def test_reused_pid(self):
    method test_pid_0 (line 1396) | def test_pid_0(self):
    method test_environ (line 1443) | def test_environ(self):
    method test_weird_environ (line 1478) | def test_weird_environ(self):
  class TestProcessWait (line 1523) | class TestProcessWait(PsutilTestCase):
    method test_wait_exited (line 1525) | def test_wait_exited(self):
    method test_wait_signaled (line 1553) | def test_wait_signaled(self):
    method test_wait_stopped (line 1567) | def test_wait_stopped(self):
    method test_wait_non_children (line 1592) | def test_wait_non_children(self):
    method test_wait_timeout (line 1615) | def test_wait_timeout(self):
    method test_wait_timeout_nonblocking (line 1623) | def test_wait_timeout_nonblocking(self):
    method test_wait_errors (line 1643) | def test_wait_errors(self):
    method test_wait_zombie (line 1654) | def test_wait_zombie(self):
    method test_os_waitpid_error (line 1665) | def test_os_waitpid_error(self):
    method test_os_waitpid_bad_ret_status (line 1676) | def test_os_waitpid_bad_ret_status(self):
    method assert_wait_pid_errors (line 1685) | def assert_wait_pid_errors(self, patch_target, wait_func, errors):
    method test_pidfd_open_errors (line 1707) | def test_pidfd_open_errors(self):
    method test_kqueue_errors (line 1719) | def test_kqueue_errors(self):
    method assert_wait_pid_race (line 1728) | def assert_wait_pid_race(self, patch_target, real_func):
    method test_pidfd_open_race (line 1748) | def test_pidfd_open_race(self):
    method test_kqueue_race (line 1754) | def test_kqueue_race(self):
    method test_kqueue_control_errors (line 1760) | def test_kqueue_control_errors(self):
  class TestPopen (line 1796) | class TestPopen(PsutilTestCase):
    method tearDownClass (line 1800) | def tearDownClass(cls):
    method test_misc (line 1804) | def test_misc(self):
    method test_ctx_manager (line 1831) | def test_ctx_manager(self):
    method test_kill_terminate (line 1845) | def test_kill_terminate(self):
    method test__getattribute__ (line 1874) | def test__getattribute__(self):

FILE: tests/test_process_all.py
  function proc_info (line 49) | def proc_info(pid):
  class TestFetchAllProcesses (line 103) | class TestFetchAllProcesses(PsutilTestCase):
    method setUp (line 109) | def setUp(self):
    method tearDown (line 123) | def tearDown(self):
    method iter_proc_info (line 129) | def iter_proc_info(self):
    method test_all (line 140) | def test_all(self):
    method cmdline (line 164) | def cmdline(self, ret, info):
    method exe (line 169) | def exe(self, ret, info):
    method pid (line 188) | def pid(self, ret, info):
    method ppid (line 192) | def ppid(self, ret, info):
    method name (line 197) | def name(self, ret, info):
    method create_time (line 206) | def create_time(self, ret, info):
    method uids (line 222) | def uids(self, ret, info):
    method gids (line 227) | def gids(self, ret, info):
    method username (line 235) | def username(self, ret, info):
    method status (line 240) | def status(self, ret, info):
    method io_counters (line 246) | def io_counters(self, ret, info):
    method ionice (line 252) | def ionice(self, ret, info):
    method num_threads (line 269) | def num_threads(self, ret, info):
    method threads (line 276) | def threads(self, ret, info):
    method cpu_times (line 285) | def cpu_times(self, ret, info):
    method cpu_percent (line 291) | def cpu_percent(self, ret, info):
    method cpu_num (line 295) | def cpu_num(self, ret, info):
    method memory_info (line 304) | def memory_info(self, ret, info):
    method memory_info_ex (line 307) | def memory_info_ex(self, ret, info):
    method memory_footprint (line 310) | def memory_footprint(self, ret, info):
    method open_files (line 316) | def open_files(self, ret, info):
    method num_fds (line 342) | def num_fds(self, ret, info):
    method net_connections (line 346) | def net_connections(self, ret, info):
    method cwd (line 352) | def cwd(self, ret, info):
    method memory_percent (line 368) | def memory_percent(self, ret, info):
    method is_running (line 372) | def is_running(self, ret, info):
    method cpu_affinity (line 375) | def cpu_affinity(self, ret, info):
    method terminal (line 383) | def terminal(self, ret, info):
    method memory_maps (line 389) | def memory_maps(self, ret, info):
    method num_handles (line 416) | def num_handles(self, ret, info):
    method page_faults (line 420) | def page_faults(self, ret, info):
    method nice (line 426) | def nice(self, ret, info):
    method num_ctx_switches (line 439) | def num_ctx_switches(self, ret, info):
    method rlimit (line 444) | def rlimit(self, ret, info):
    method environ (line 450) | def environ(self, ret, info):
  class TestPidsRange (line 457) | class TestPidsRange(PsutilTestCase):
    method setUp (line 474) | def setUp(self):
    method tearDown (line 477) | def tearDown(self):
    method test_it (line 480) | def test_it(self):

FILE: tests/test_scripts.py
  class TestExampleScripts (line 48) | class TestExampleScripts(PsutilTestCase):
    method assert_stdout (line 50) | def assert_stdout(exe, *args):
    method assert_syntax (line 66) | def assert_syntax(exe):
    method test_coverage (line 72) | def test_coverage(self):
    method test_executable (line 85) | def test_executable(self):
    method test_disk_usage (line 93) | def test_disk_usage(self):
    method test_free (line 96) | def test_free(self):
    method test_meminfo (line 99) | def test_meminfo(self):
    method test_procinfo (line 102) | def test_procinfo(self):
    method test_who (line 106) | def test_who(self):
    method test_ps (line 109) | def test_ps(self):
    method test_pstree (line 112) | def test_pstree(self):
    method test_netstat (line 115) | def test_netstat(self):
    method test_ifconfig (line 118) | def test_ifconfig(self):
    method test_pmap (line 122) | def test_pmap(self):
    method test_procsmem (line 126) | def test_procsmem(self):
    method test_killall (line 129) | def test_killall(self):
    method test_nettop (line 132) | def test_nettop(self):
    method test_top (line 135) | def test_top(self):
    method test_iotop (line 138) | def test_iotop(self):
    method test_pidof (line 141) | def test_pidof(self):
    method test_winservices (line 146) | def test_winservices(self):
    method test_cpu_distribution (line 149) | def test_cpu_distribution(self):
    method test_temperatures (line 153) | def test_temperatures(self):
    method test_fans (line 159) | def test_fans(self):
    method test_battery (line 166) | def test_battery(self):
    method test_sensors (line 171) | def test_sensors(self):
  class TestInternalScripts (line 184) | class TestInternalScripts(PsutilTestCase):
    method ls (line 186) | def ls():
    method test_syntax_all (line 191) | def test_syntax_all(self):
    method test_import_all (line 200) | def test_import_all(self):

FILE: tests/test_sudo.py
  function get_systime (line 28) | def get_systime():
  function set_systime (line 34) | def set_systime(secs):  # secs since the epoch
  class TestUpdatedSystemTime (line 64) | class TestUpdatedSystemTime(PsutilTestCase):
    method setUp (line 67) | def setUp(self):
    method tearDown (line 72) | def tearDown(self):
    method update_systime (line 77) | def update_systime(self):
    method test_boot_time (line 82) | def test_boot_time(self):
    method test_proc_create_time (line 92) | def test_proc_create_time(self):
    method test_proc_ident (line 105) | def test_proc_ident(self):
    method test_linux_monotonic_proc_time (line 113) | def test_linux_monotonic_proc_time(self):

FILE: tests/test_sunos.py
  class SunOSSpecificTestCase (line 20) | class SunOSSpecificTestCase(PsutilTestCase):
    method test_swap_memory (line 21) | def test_swap_memory(self):
    method test_cpu_count (line 38) | def test_cpu_count(self):

FILE: tests/test_system.py
  class TestProcessIter (line 59) | class TestProcessIter(PsutilTestCase):
    method test_pid_presence (line 60) | def test_pid_presence(self):
    method test_no_duplicates (line 69) | def test_no_duplicates(self):
    method test_emulate_nsp (line 75) | def test_emulate_nsp(self):
    method test_emulate_access_denied (line 85) | def test_emulate_access_denied(self):
    method test_attrs (line 96) | def test_attrs(self):
    method test_cache_clear (line 124) | def test_cache_clear(self):
  class TestProcessAPIs (line 131) | class TestProcessAPIs(PsutilTestCase):
    method test_wait_procs (line 136) | def test_wait_procs(self):
    method test_wait_procs_no_timeout (line 199) | def test_wait_procs_no_timeout(self):
    method test_pid_exists (line 208) | def test_pid_exists(self):
    method test_pid_exists_2 (line 218) | def test_pid_exists_2(self):
  class TestMiscAPIs (line 233) | class TestMiscAPIs(PsutilTestCase):
    method test_boot_time (line 234) | def test_boot_time(self):
    method test_users (line 243) | def test_users(self):
    method test_heap_info (line 263) | def test_heap_info(self):
    method test_heap_trim (line 274) | def test_heap_trim(self):
    method test_os_constants (line 277) | def test_os_constants(self):
  class TestMemoryAPIs (line 327) | class TestMemoryAPIs(PsutilTestCase):
    method test_virtual_memory (line 328) | def test_virtual_memory(self):
    method test_virtual_memory_fields_order (line 347) | def test_virtual_memory_fields_order(self):
    method test_swap_memory (line 383) | def test_swap_memory(self):
  class TestCpuAPIs (line 406) | class TestCpuAPIs(PsutilTestCase):
    method test_cpu_count_logical (line 407) | def test_cpu_count_logical(self):
    method test_cpu_count_cores (line 419) | def test_cpu_count_cores(self):
    method test_cpu_count_none (line 430) | def test_cpu_count_none(self):
    method test_cpu_times (line 444) | def test_cpu_times(self):
    method test_cpu_times_time_increases (line 472) | def test_cpu_times_time_increases(self):
    method test_per_cpu_times (line 482) | def test_per_cpu_times(self):
    method test_per_cpu_times_2 (line 515) | def test_per_cpu_times_2(self):
    method test_cpu_times_comparison (line 534) | def test_cpu_times_comparison(self):
    method _test_cpu_percent (line 550) | def _test_cpu_percent(self, percent, last_ret, new_ret):
    method test_cpu_percent (line 562) | def test_cpu_percent(self):
    method test_per_cpu_percent (line 571) | def test_per_cpu_percent(self):
    method test_cpu_times_percent (line 582) | def test_cpu_times_percent(self):
    method test_per_cpu_times_percent (line 593) | def test_per_cpu_times_percent(self):
    method test_per_cpu_times_percent_negative (line 604) | def test_per_cpu_times_percent_negative(self):
    method test_cpu_stats (line 616) | def test_cpu_stats(self):
    method test_cpu_freq (line 633) | def test_cpu_freq(self):
    method test_getloadavg (line 654) | def test_getloadavg(self):
  class TestDiskAPIs (line 662) | class TestDiskAPIs(PsutilTestCase):
    method test_disk_usage (line 663) | def test_disk_usage(self):
    method test_disk_usage_unicode (line 688) | def test_disk_usage_unicode(self):
    method test_disk_usage_bytes (line 693) | def test_disk_usage_bytes(self):
    method test_disk_partitions (line 696) | def test_disk_partitions(self):
    method test_disk_io_counters (line 760) | def test_disk_io_counters(self):
    method test_disk_io_counters_no_disks (line 788) | def test_disk_io_counters_no_disks(self):
  class TestNetAPIs (line 799) | class TestNetAPIs(PsutilTestCase):
    method test_net_io_counters (line 801) | def test_net_io_counters(self):
    method test_net_io_counters_no_nics (line 830) | def test_net_io_counters_no_nics(self):
    method test_net_if_addrs (line 840) | def test_net_if_addrs(self):
    method test_net_if_addrs_mac_null_bytes (line 915) | def test_net_if_addrs_mac_null_bytes(self):
    method test_net_if_stats (line 933) | def test_net_if_stats(self):
    method test_net_if_stats_enodev (line 954) | def test_net_if_stats_enodev(self):
  class TestSensorsAPIs (line 965) | class TestSensorsAPIs(PsutilTestCase):
    method test_sensors_temperatures (line 967) | def test_sensors_temperatures(self):
    method test_sensors_temperatures_fahreneit (line 981) | def test_sensors_temperatures_fahreneit(self):
    method test_sensors_battery (line 994) | def test_sensors_battery(self):
    method test_sensors_fans (line 1008) | def test_sensors_fans(self):

FILE: tests/test_testutils.py
  class TestRetryDecorator (line 56) | class TestRetryDecorator(PsutilTestCase):
    method test_retry_success (line 58) | def test_retry_success(self, sleep):
    method test_retry_failure (line 73) | def test_retry_failure(self, sleep):
    method test_exception_arg (line 88) | def test_exception_arg(self, sleep):
    method test_no_interval_arg (line 98) | def test_no_interval_arg(self, sleep):
    method test_retries_arg (line 110) | def test_retries_arg(self, sleep):
    method test_retries_and_timeout_args (line 120) | def test_retries_and_timeout_args(self, sleep):
  class TestSyncTestUtils (line 125) | class TestSyncTestUtils(PsutilTestCase):
    method test_wait_for_pid (line 126) | def test_wait_for_pid(self):
    method test_wait_for_file (line 133) | def test_wait_for_file(self):
    method test_wait_for_file_empty (line 140) | def test_wait_for_file_empty(self):
    method test_wait_for_file_no_file (line 147) | def test_wait_for_file_no_file(self):
    method test_wait_for_file_no_delete (line 153) | def test_wait_for_file_no_delete(self):
    method test_call_until (line 160) | def test_call_until(self):
  class TestFSTestUtils (line 165) | class TestFSTestUtils(PsutilTestCase):
    method test_open_text (line 166) | def test_open_text(self):
    method test_open_binary (line 170) | def test_open_binary(self):
    method test_safe_mkdir (line 174) | def test_safe_mkdir(self):
    method test_safe_rmpath (line 181) | def test_safe_rmpath(self):
    method test_chdir (line 201) | def test_chdir(self):
  class TestProcessUtils (line 210) | class TestProcessUtils(PsutilTestCase):
    method test_reap_children (line 211) | def test_reap_children(self):
    method test_spawn_children_pair (line 220) | def test_spawn_children_pair(self):
    method test_spawn_zombie (line 242) | def test_spawn_zombie(self):
    method test_terminate (line 246) | def test_terminate(self):
  class TestNetUtils (line 286) | class TestNetUtils(PsutilTestCase):
    method bind_socket (line 287) | def bind_socket(self):
    method test_bind_unix_socket (line 293) | def test_bind_unix_socket(self):
    method test_tcp_socketpair (line 306) | def test_tcp_socketpair(self):
    method test_unix_socketpair (line 322) | def test_unix_socketpair(self):
    method test_create_sockets (line 344) | def test_create_sockets(self):
  class TestTestingUtils (line 361) | class TestTestingUtils(PsutilTestCase):
    method test_process_namespace (line 362) | def test_process_namespace(self):
    method test_system_namespace (line 369) | def test_system_namespace(self):
  class TestOtherUtils (line 375) | class TestOtherUtils(PsutilTestCase):
    method test_is_namedtuple (line 376) | def test_is_namedtuple(self):

FILE: tests/test_type_hints.py
  class TypeHintTestCase (line 28) | class TypeHintTestCase(PsutilTestCase):
  class TestTypeHintsNtuples (line 37) | class TestTypeHintsNtuples(TypeHintTestCase):
    method check_result (line 42) | def check_result(self, ret):
    method test_system_ntuple_types (line 50) | def test_system_ntuple_types(self):
    method test_process_ntuple_types (line 67) | def test_process_ntuple_types(self):
  class TestTypeHintsReturned (line 84) | class TestTypeHintsReturned(TypeHintTestCase):
    method check (line 89) | def check(self, fun, name):
    method test_system_return_types (line 96) | def test_system_return_types(self):
    method test_process_return_types (line 101) | def test_process_return_types(self):
  class TestCheckNtupleTypeHints (line 114) | class TestCheckNtupleTypeHints(TypeHintTestCase):
    method test_not_namedtuple (line 115) | def test_not_namedtuple(self):
    method test_ok (line 120) | def test_ok(self):
    method test_wrong_type (line 126) | def test_wrong_type(self):
    method test_union_with_none (line 136) | def test_union_with_none(self):
    method test_intenum_broadening (line 145) | def test_intenum_broadening(self):
  class TestCheckFunTypeHints (line 158) | class TestCheckFunTypeHints(TypeHintTestCase):
    method test_no_annotation (line 163) | def test_no_annotation(self):
    method test_float (line 170) | def test_float(self):
    method test_bool (line 178) | def test_bool(self):
    method test_list (line 189) | def test_list(self):
    method test_list_container (line 200) | def test_list_container(self):
    method test_dict (line 211) | def test_dict(self):
    method test_dict_container (line 222) | def test_dict_container(self):
    method test_namedtuple (line 230) | def test_namedtuple(self):
    method test_union_with_none (line 243) | def test_union_with_none(self):
    method test_union_or_dict_or_none (line 255) | def test_union_or_dict_or_none(self):
    method test_generator (line 265) | def test_generator(self):
    method test_partial (line 275) | def test_partial(self):
    method test_bound_method (line 284) | def test_bound_method(self):

FILE: tests/test_unicode.py
  function try_unicode (line 105) | def try_unicode(suffix):
  class BaseUnicodeTest (line 132) | class BaseUnicodeTest(PsutilTestCase):
    method setUpClass (line 136) | def setUpClass(cls):
    method setUp (line 147) | def setUp(self):
  class TestFSAPIs (line 155) | class TestFSAPIs(BaseUnicodeTest):
    method expect_exact_path_match (line 160) | def expect_exact_path_match(self):
    method test_proc_exe (line 167) | def test_proc_exe(self):
    method test_proc_name (line 180) | def test_proc_name(self):
    method test_proc_cmdline (line 192) | def test_proc_cmdline(self):
    method test_proc_cwd (line 206) | def test_proc_cwd(self):
    method test_proc_open_files (line 221) | def test_proc_open_files(self):
    method test_proc_net_connections (line 238) | def test_proc_net_connections(self):
    method test_net_connections (line 253) | def test_net_connections(self):
    method test_disk_usage (line 268) | def test_disk_usage(self):
    method test_memory_maps (line 275) | def test_memory_maps(self):
  class TestFSAPIsWithInvalidPath (line 292) | class TestFSAPIsWithInvalidPath(TestFSAPIs):
    method expect_exact_path_match (line 297) | def expect_exact_path_match(self):
  class TestNonFSAPIS (line 306) | class TestNonFSAPIS(BaseUnicodeTest):
    method test_proc_environ (line 313) | def test_proc_environ(self):

FILE: tests/test_windows.py
  class WindowsTestCase (line 59) | class WindowsTestCase(PsutilTestCase):
    method OpenProcess (line 61) | def OpenProcess(self, pid=None):
  function is_bash_env (line 72) | def is_bash_env():
  function powershell (line 79) | def powershell(cmd):
  function wmic (line 102) | def wmic(path, what, converter=int):
  class TestCpuAPIs (line 124) | class TestCpuAPIs(WindowsTestCase):
    method test_cpu_count_vs_NUMBER_OF_PROCESSORS (line 129) | def test_cpu_count_vs_NUMBER_OF_PROCESSORS(self):
    method test_cpu_count_vs_GetSystemInfo (line 135) | def test_cpu_count_vs_GetSystemInfo(self):
    method test_cpu_count_logical_vs_wmi (line 140) | def test_cpu_count_logical_vs_wmi(self):
    method test_cpu_count_cores_vs_wmi (line 147) | def test_cpu_count_cores_vs_wmi(self):
    method test_cpu_count_vs_cpu_times (line 152) | def test_cpu_count_vs_cpu_times(self):
    method test_cpu_times_irq_field (line 155) | def test_cpu_times_irq_field(self):
    method test_cpu_freq (line 161) | def test_cpu_freq(self):
  class TestVirtualMemory (line 168) | class TestVirtualMemory(WindowsTestCase):
    method test_total (line 170) | def test_total(self):
    method test_free (line 174) | def test_free(self):
    method test_wired (line 182) | def test_wired(self):
  class TestSystemAPIs (line 190) | class TestSystemAPIs(WindowsTestCase):
    method test_nic_names (line 191) | def test_nic_names(self):
    method test_net_if_addrs (line 202) | def test_net_if_addrs(self):
    method test_net_connections (line 214) | def test_net_connections(self):
    method test_total_swapmem (line 228) | def test_total_swapmem(self):
    method test_percent_swapmem (line 238) | def test_percent_swapmem(self):
    method test_pids (line 262) | def test_pids(self):
    method test_disks (line 271) | def test_disks(self):
    method test_disk_usage (line 302) | def test_disk_usage(self):
    method test_disk_partitions (line 312) | def test_disk_partitions(self):
    method test_convert_dos_path_drive (line 325) | def test_convert_dos_path_drive(self):
    method test_convert_dos_path_unc (line 345) | def test_convert_dos_path_unc(self):
    method test_net_if_stats (line 357) | def test_net_if_stats(self):
    method test_boot_time (line 368) | def test_boot_time(self):
    method test_uptime (line 378) | def test_uptime(self):
  class TestSensorsBattery (line 391) | class TestSensorsBattery(WindowsTestCase):
    method test_has_battery (line 392) | def test_has_battery(self):
    method test_percent (line 399) | def test_percent(self):
    method test_power_plugged (line 409) | def test_power_plugged(self):
    method test_secsleft (line 418) | def test_secsleft(self):
    method test_emulate_no_battery (line 440) | def test_emulate_no_battery(self):
    method test_emulate_power_connected (line 448) | def test_emulate_power_connected(self):
    method test_emulate_power_charging (line 458) | def test_emulate_power_charging(self):
    method test_emulate_secs_left_unknown (line 468) | def test_emulate_secs_left_unknown(self):
  class TestProcess (line 484) | class TestProcess(WindowsTestCase):
    method setUpClass (line 486) | def setUpClass(cls):
    method tearDownClass (line 490) | def tearDownClass(cls):
    method test_issue_24 (line 493) | def test_issue_24(self):
    method test_special_pid (line 498) | def test_special_pid(self):
    method test_send_signal (line 515) | def test_send_signal(self):
    method test_num_handles_increment (line 520) | def test_num_handles_increment(self):
    method test_ctrl_signals (line 529) | def test_ctrl_signals(self):
    method test_username (line 540) | def test_username(self):
    method test_cmdline (line 549) | def test_cmdline(self):
    method test_nice (line 568) | def test_nice(self):
    method test_memory_info (line 573) | def test_memory_info(self):
    method test_memory_info_deprecated_fields (line 583) | def test_memory_info_deprecated_fields(self):
    method test_memory_info_ex (line 629) | def test_memory_info_ex(self):
    method test_wait (line 644) | def test_wait(self):
    method test_num_threads (line 651) | def test_num_threads(self):
    method test_cpu_affinity (line 656) | def test_cpu_affinity(self):
    method test_io_counters (line 666) | def test_io_counters(self):
    method test_num_handles (line 676) | def test_num_handles(self):
    method test_error_partial_copy (line 691) | def test_error_partial_copy(self):
    method test_exe (line 702) | def test_exe(self):
    method test_page_faults (line 711) | def test_page_faults(self):
  class TestProcessWMI (line 722) | class TestProcessWMI(WindowsTestCase):
    method setUpClass (line 726) | def setUpClass(cls):
    method tearDownClass (line 730) | def tearDownClass(cls):
    method test_name (line 733) | def test_name(self):
    method test_exe (line 742) | def test_exe(self):
    method test_cmdline (line 749) | def test_cmdline(self):
    method test_username (line 754) | def test_username(self):
    method test_memory_rss (line 762) | def test_memory_rss(self):
    method test_memory_vms (line 769) | def test_memory_vms(self):
    method test_cpu_times (line 781) | def test_cpu_times(self):
    method test_ppid (line 788) | def test_ppid(self):
    method test_create_time (line 793) | def test_create_time(self):
  class TestDualProcessImplementation (line 807) | class TestDualProcessImplementation(PsutilTestCase):
    method setUpClass (line 818) | def setUpClass(cls):
    method tearDownClass (line 822) | def tearDownClass(cls):
    method test_memory_info (line 825) | def test_memory_info(self):
    method test_create_time (line 839) | def test_create_time(self):
    method test_cpu_times (line 848) | def test_cpu_times(self):
    method test_io_counters (line 859) | def test_io_counters(self):
    method test_num_handles (line 870) | def test_num_handles(self):
    method test_cmdline (line 879) | def test_cmdline(self):
  class RemoteProcessTestCase (line 895) | class RemoteProcessTestCase(PsutilTestCase):
    method find_other_interpreter (line 903) | def find_other_interpreter():
    method setUp (line 922) | def setUp(self):
    method tearDown (line 946) | def tearDown(self):
    method test_cmdline_32 (line 951) | def test_cmdline_32(self):
    method test_cmdline_64 (line 956) | def test_cmdline_64(self):
    method test_cwd_32 (line 961) | def test_cwd_32(self):
    method test_cwd_64 (line 965) | def test_cwd_64(self):
    method test_environ_32 (line 969) | def test_environ_32(self):
    method test_environ_64 (line 975) | def test_environ_64(self):
  class TestServices (line 989) | class TestServices(PsutilTestCase):
    method test_win_service_iter (line 990) | def test_win_service_iter(self):
    method test_win_service_get (line 1039) | def test_win_service_get(self):
Condensed preview — 238 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,250K chars).
[
  {
    "path": ".clang-format",
    "chars": 1874,
    "preview": "# Re-adapted from: https://gist.github.com/JPHutchins/6ef33a52cc92fc4a71996b32b11724b4\n# clang-format doc: https://clang"
  },
  {
    "path": ".dprint.jsonc",
    "chars": 751,
    "preview": "{\n    \"markdown\": {\n        \"lineWidth\": 79,\n        \"textWrap\": \"always\",\n    },\n    \"json\": {\n        \"indentWidth\": 4"
  },
  {
    "path": ".github/FUNDING.yml",
    "chars": 392,
    "preview": "# These are supported funding model platforms\n\ntidelift: \"pypi/psutil\"\ngithub: giampaolo\npatreon: # Replace with a singl"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug.md",
    "chars": 536,
    "preview": "---\nname: Bug\nabout: Report a bug\ntitle: \"[OS] title\"\nlabels: 'bug'\n---\n\n## Summary\n\n- OS: { type-or-version }\n- Archite"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "chars": 151,
    "preview": "blank_issues_enabled: false\ncontact_links:\n  - name: Ask a question\n    url: https://groups.google.com/g/psutil\n    abou"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/enhancement.md",
    "chars": 391,
    "preview": "---\nname: Enhancement\nabout: Propose an enhancement\nlabels: 'enhancement'\ntitle: \"[OS] title\"\n---\n\n## Summary\n\n- OS: { t"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "chars": 396,
    "preview": "## Summary\n\n- OS: { type-or-version }\n- Bug fix: { yes/no }\n- Type: { core, doc, performance, scripts, tests, wheels, ne"
  },
  {
    "path": ".github/no-response.yml",
    "chars": 575,
    "preview": "# Configuration for probot-no-response: https://github.com/probot/no-response\n\n# Number of days of inactivity before an "
  },
  {
    "path": ".github/placeholder",
    "chars": 0,
    "preview": ""
  },
  {
    "path": ".github/workflows/bsd.yml",
    "chars": 1692,
    "preview": "# Execute tests on *BSD platforms. Does not produce wheels.\n# Useful URLs:\n# https://github.com/vmactions/freebsd-vm\n# h"
  },
  {
    "path": ".github/workflows/build.yml",
    "chars": 2705,
    "preview": "# Runs CI tests and generates wheels on the following platforms:\n# * Linux\n# * macOS\n# * Windows\n#\n# Useful URLs:\n# * ht"
  },
  {
    "path": ".github/workflows/changelog_bot.py",
    "chars": 15158,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": ".github/workflows/changelog_bot.yml",
    "chars": 2908,
    "preview": "name: changelog-bot\n\non:\n  issue_comment:\n    types: [created]\n\npermissions:\n  contents: write\n  pull-requests: write\n\nj"
  },
  {
    "path": ".github/workflows/issues.py",
    "chars": 9525,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": ".github/workflows/issues.yml",
    "chars": 737,
    "preview": "# Fired by Github Actions every time an issue, PR or comment is created.\n\nname: issues\non:\n  issues:\n    types: [opened]"
  },
  {
    "path": ".github/workflows/sunos.yml",
    "chars": 1226,
    "preview": "# Execute tests on SunOS\n# https://github.com/vmactions/solaris-vm\n\nname: sunos\non:\n  push:\n    # only run this job if t"
  },
  {
    "path": ".gitignore",
    "chars": 170,
    "preview": "syntax: glob\n*.al\n*.bak\n*.egg-info\n*.la\n*.lo\n*.o\n*.orig\n*.pyc\n*.pyd\n*.rej\n*.so\n*.swp\n.failed-tests.txt\n.cache/\n.idea/\n.t"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 1621,
    "preview": "# Contributing to psutil project\n\n## Issues\n\n- The issue tracker is for reporting problems or proposing enhancements rel"
  },
  {
    "path": "HISTORY.rst",
    "chars": 143,
    "preview": "History has moved to:\n\n- https://psutil.readthedocs.io/changelog\n- https://github.com/giampaolo/psutil/blob/master/docs/"
  },
  {
    "path": "INSTALL.rst",
    "chars": 158,
    "preview": "Installation instructions have moved to:\n\n- https://psutil.readthedocs.io/install\n- https://github.com/giampaolo/psutil/"
  },
  {
    "path": "LICENSE",
    "chars": 1548,
    "preview": "BSD 3-Clause License\n\nCopyright (c) 2009, Jay Loden, Dave Daeschler, Giampaolo Rodola\nAll rights reserved.\n\nRedistributi"
  },
  {
    "path": "MANIFEST.in",
    "chars": 7127,
    "preview": "include .clang-format\ninclude .dprint.jsonc\ninclude .gitignore\ninclude CONTRIBUTING.md\ninclude HISTORY.rst\ninclude INSTA"
  },
  {
    "path": "Makefile",
    "chars": 14169,
    "preview": "# Shortcuts for various development tasks.\n#\n# - To use this on Windows install Git For Windows first, then launch a Git"
  },
  {
    "path": "README.rst",
    "chars": 25653,
    "preview": "|  |downloads| |stars| |forks| |contributors| |packages|\n|  |version| |license| |stackoverflow| |twitter| |tidelift|\n|  "
  },
  {
    "path": "SECURITY.md",
    "chars": 472,
    "preview": "# Security Policy\n\nIf you have discovered a security vulnerability in this project, please report\nit privately. **Do not"
  },
  {
    "path": "_bootstrap.py",
    "chars": 1229,
    "preview": "# Copyright (c) 2009 Giampaolo Rodola. All rights reserved.\n# Use of this source code is governed by a BSD-style license"
  },
  {
    "path": "docs/.readthedocs.yaml",
    "chars": 505,
    "preview": "# .readthedocs.yaml\n# Read the Docs configuration file\n# See https://docs.readthedocs.io/en/stable/config-file/v2.html f"
  },
  {
    "path": "docs/DEVNOTES",
    "chars": 4653,
    "preview": "TODO\n====\n\nA collection of ideas and notes about stuff to implement in future versions.\n\"#NNN\" occurrences refer to bug "
  },
  {
    "path": "docs/Makefile",
    "chars": 1285,
    "preview": "# Makefile for Sphinx documentation\n\nPYTHON = python3\nSPHINXBUILD = $(PYTHON) -m sphinx\nBUILDDIR = _build\nALLSPHINXOPTS "
  },
  {
    "path": "docs/README",
    "chars": 385,
    "preview": "About\n=====\n\nThis directory contains the reStructuredText (reST) sources to the psutil\ndocumentation.  You don't need to"
  },
  {
    "path": "docs/_ext/add_home_link.py",
    "chars": 825,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "docs/_ext/availability.py",
    "chars": 2961,
    "preview": "# noqa: CPY001\n\n# Slightly adapted from CPython's:\n# https://github.com/python/cpython/blob/main/Doc/tools/extensions/av"
  },
  {
    "path": "docs/_ext/changelog_anchors.py",
    "chars": 965,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "docs/_ext/check_python_syntax.py",
    "chars": 1166,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "docs/_links.rst",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "docs/_static/copybutton.js",
    "chars": 2495,
    "preview": "$(document).ready(function() {\n    /* Add a [>>>] button on the top-right corner of code samples to hide\n     * the >>> "
  },
  {
    "path": "docs/_static/css/custom.css",
    "chars": 6918,
    "preview": "/* ================================================================== */\n/* Layout                                      "
  },
  {
    "path": "docs/_static/sidebar.js",
    "chars": 5162,
    "preview": "/*\n * sidebar.js\n * ~~~~~~~~~~\n *\n * This script makes the Sphinx sidebar collapsible.\n *\n * .sphinxsidebar contains .sp"
  },
  {
    "path": "docs/_templates/layout.html",
    "chars": 367,
    "preview": "{% extends \"!layout.html\" %}\n{% block extrahead %}\n{{ super() }}\n<!-- Google tag (gtag.js) -->\n<script async src=\"https:"
  },
  {
    "path": "docs/adoption.rst",
    "chars": 11453,
    "preview": ".. currentmodule:: psutil\n\nWho uses psutil\n===============\n\npsutil is among the `top 100 <https://clickpy.clickhouse.com"
  },
  {
    "path": "docs/alternatives.rst",
    "chars": 6362,
    "preview": ".. currentmodule:: psutil\n\nAlternatives\n============\n\nThis page describes Python tools and modules that overlap with psu"
  },
  {
    "path": "docs/api.rst",
    "chars": 131040,
    "preview": ".. currentmodule:: psutil\n.. include:: _links.rst\n.. _availability:\n\nAPI reference\n=============\n\n.. note::\n   psutil 8."
  },
  {
    "path": "docs/changelog.rst",
    "chars": 130194,
    "preview": ".. currentmodule:: psutil\n\nChangelog\n=========\n\n8.0.0 (IN DEVELOPMENT)\n^^^^^^^^^^^^^^^^^^^^^^\n\n**Compatibility notes**\n\n"
  },
  {
    "path": "docs/conf.py",
    "chars": 1762,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola. All rights reserved.\n# Use of this source code is governed by a BSD-style licens"
  },
  {
    "path": "docs/credits.rst",
    "chars": 19922,
    "preview": ".. currentmodule:: psutil\n\nCredits\n=======\n\nI would like to recognize some of the people who have been instrumental in t"
  },
  {
    "path": "docs/devguide.rst",
    "chars": 6890,
    "preview": "Development guide\n=================\n\nBuild, setup and running tests\n------------------------------\n\n- psutil makes exten"
  },
  {
    "path": "docs/faq.rst",
    "chars": 10323,
    "preview": ".. currentmodule:: psutil\n\nFAQ\n===\n\nThis section answers common questions and pitfalls when using psutil.\n\n.. contents::"
  },
  {
    "path": "docs/glossary.rst",
    "chars": 13847,
    "preview": ".. currentmodule:: psutil\n\nGlossary\n========\n\n.. glossary::\n   :sorted:\n\n   anonymous memory\n\n      RAM used by the prog"
  },
  {
    "path": "docs/index.rst",
    "chars": 3916,
    "preview": ".. module:: psutil\n   :synopsis: psutil module\n.. moduleauthor:: Giampaolo Rodola <grodola@gmail.com>\n\npsutil documentat"
  },
  {
    "path": "docs/install.rst",
    "chars": 3840,
    "preview": "Install psutil\n==============\n\nLinux, Windows, macOS (wheels)\n------------------------------\n\nPre-compiled wheels are di"
  },
  {
    "path": "docs/migration.rst",
    "chars": 9131,
    "preview": ".. currentmodule:: psutil\n.. include:: _links.rst\n\nMigration guide\n===============\n\nThis page summarises the breaking ch"
  },
  {
    "path": "docs/platform.rst",
    "chars": 3670,
    "preview": "Platform support\n================\n\nPython\n^^^^^^\n\n**Current Python:** 3.7 and PyPy3.\n\n**Python 2.7**: latest psutil vers"
  },
  {
    "path": "docs/recipes.rst",
    "chars": 15697,
    "preview": "Recipes\n=======\n\nA collection of standalone, copy-paste solutions to specific problems. Each\nrecipe focuses on a single "
  },
  {
    "path": "docs/requirements.txt",
    "chars": 72,
    "preview": "sphinx\nsphinx_rtd_theme\nsphinx_copybutton\nsphinxcontrib-googleanalytics\n"
  },
  {
    "path": "docs/shell_equivalents.rst",
    "chars": 10265,
    "preview": "\n.. currentmodule:: psutil\n\nShell equivalents\n=================\n\nThis page maps psutil's Python API to the equivalent na"
  },
  {
    "path": "docs/timeline.rst",
    "chars": 21843,
    "preview": "Timeline\n========\n\n- 2026-02-08:\n  `7.2.3 <https://pypi.org/project/psutil/7.2.3/#files>`_ -\n  `what's new <changelog.ht"
  },
  {
    "path": "psutil/__init__.py",
    "chars": 93146,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/_common.py",
    "chars": 22205,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/_enums.py",
    "chars": 4162,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/_ntuples.py",
    "chars": 11235,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola\". All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/_psaix.py",
    "chars": 17730,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'\n# Copyright (c) 2017, Arnon Yaari\n# All rights reserved.\n# Use of this source co"
  },
  {
    "path": "psutil/_psbsd.py",
    "chars": 26549,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/_pslinux.py",
    "chars": 84669,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/_psosx.py",
    "chars": 14737,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/_psposix.py",
    "chars": 11345,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/_pssunos.py",
    "chars": 24197,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/_psutil_aix.c",
    "chars": 27484,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'\n * Copyright (c) 2017, Arnon Yaari\n * All rights reserved.\n * Use of this so"
  },
  {
    "path": "psutil/_psutil_bsd.c",
    "chars": 7386,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola', Landry Breuil\n * (OpenBSD implementation), Ryo Onodera (NetBSD i"
  },
  {
    "path": "psutil/_psutil_linux.c",
    "chars": 2436,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/_psutil_osx.c",
    "chars": 4996,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/_psutil_sunos.c",
    "chars": 5156,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/_psutil_windows.c",
    "chars": 10246,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/_pswindows.py",
    "chars": 35607,
    "preview": "# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is governed by a BSD-style licen"
  },
  {
    "path": "psutil/arch/aix/common.c",
    "chars": 2189,
    "preview": "/*\n * Copyright (c) 2017, Arnon Yaari\n * All rights reserved.\n * Use of this source code is governed by a BSD-style lice"
  },
  {
    "path": "psutil/arch/aix/common.h",
    "chars": 797,
    "preview": "/*\n * Copyright (c) 2017, Arnon Yaari\n * All rights reserved.\n * Use of this source code is governed by a BSD-style lice"
  },
  {
    "path": "psutil/arch/aix/ifaddrs.c",
    "chars": 3914,
    "preview": "/*\n * Copyright (c) 2017, Arnon Yaari\n * All rights reserved.\n * Use of this source code is governed by a BSD-style lice"
  },
  {
    "path": "psutil/arch/aix/ifaddrs.h",
    "chars": 749,
    "preview": "/*\n * Copyright (c) 2017, Arnon Yaari\n * All rights reserved.\n * Use of this source code is governed by a BSD-style lice"
  },
  {
    "path": "psutil/arch/aix/net_connections.c",
    "chars": 8354,
    "preview": "/*\n * Copyright (c) 2017, Arnon Yaari\n * All rights reserved.\n * Use of this source code is governed by a BSD-style lice"
  },
  {
    "path": "psutil/arch/aix/net_connections.h",
    "chars": 353,
    "preview": "/*\n * Copyright (c) 2017, Arnon Yaari\n * All rights reserved.\n * Use of this source code is governed by a BSD-style lice"
  },
  {
    "path": "psutil/arch/aix/net_kernel_structs.h",
    "chars": 3467,
    "preview": "/*\n * Copyright (c) 2017, Arnon Yaari\n * All rights reserved.\n * Use of this source code is governed by a BSD-style lice"
  },
  {
    "path": "psutil/arch/all/errors.c",
    "chars": 2573,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/all/init.c",
    "chars": 1017,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/all/init.h",
    "chars": 5146,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/all/pids.c",
    "chars": 1527,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/all/str.c",
    "chars": 2902,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola. All rights reserved.\n * Use of this source code is governed by a BSD-style l"
  },
  {
    "path": "psutil/arch/all/utils.c",
    "chars": 2011,
    "preview": "#include <Python.h>\n#include <stdarg.h>\n#include <math.h>\n\n\n// Build a Python object from a format string, append it to "
  },
  {
    "path": "psutil/arch/bsd/cpu.c",
    "chars": 1497,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/bsd/disk.c",
    "chars": 4979,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/bsd/heap.c",
    "chars": 3138,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/bsd/init.c",
    "chars": 692,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/bsd/init.h",
    "chars": 1384,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/bsd/mem.c",
    "chars": 2323,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/bsd/net.c",
    "chars": 2556,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/bsd/proc.c",
    "chars": 14883,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/bsd/proc_utils.c",
    "chars": 3123,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/bsd/sys.c",
    "chars": 695,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/freebsd/cpu.c",
    "chars": 4710,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/freebsd/disk.c",
    "chars": 2547,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/freebsd/init.h",
    "chars": 1715,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Jay Loden.\n * All rights reserved.\n * Use of this source code is governed b"
  },
  {
    "path": "psutil/arch/freebsd/mem.c",
    "chars": 5227,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/freebsd/pids.c",
    "chars": 1243,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/freebsd/proc.c",
    "chars": 14735,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/freebsd/proc_socks.c",
    "chars": 11332,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'.\n * All rights reserved.\n * Use of this source code is governed by a BSD-sty"
  },
  {
    "path": "psutil/arch/freebsd/sensors.c",
    "chars": 2315,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/freebsd/sys_socks.c",
    "chars": 12511,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'.\n * All rights reserved.\n * Use of this source code is governed by a BSD-sty"
  },
  {
    "path": "psutil/arch/linux/disk.c",
    "chars": 1946,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/linux/heap.c",
    "chars": 2286,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/linux/init.h",
    "chars": 1101,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/linux/mem.c",
    "chars": 769,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/linux/net.c",
    "chars": 3284,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/linux/proc.c",
    "chars": 5212,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/netbsd/cpu.c",
    "chars": 2447,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/netbsd/disk.c",
    "chars": 1777,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/netbsd/init.h",
    "chars": 1133,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'.\n * Copyright (c) 2015, Ryo ONODERA.\n * All rights reserved.\n * Use of this "
  },
  {
    "path": "psutil/arch/netbsd/mem.c",
    "chars": 3915,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/netbsd/pids.c",
    "chars": 1366,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola.\n * All rights reserved.\n * Use of this source code is governed by a BSD-styl"
  },
  {
    "path": "psutil/arch/netbsd/proc.c",
    "chars": 6591,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/netbsd/socks.c",
    "chars": 12699,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'.\n * Copyright (c) 2015, Ryo ONODERA.\n * All rights reserved.\n * Use of this "
  },
  {
    "path": "psutil/arch/openbsd/cpu.c",
    "chars": 2366,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/openbsd/disk.c",
    "chars": 1420,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/openbsd/init.h",
    "chars": 952,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/openbsd/mem.c",
    "chars": 3047,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/openbsd/pids.c",
    "chars": 1363,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola.\n * All rights reserved.\n * Use of this source code is governed by a BSD-styl"
  },
  {
    "path": "psutil/arch/openbsd/proc.c",
    "chars": 4849,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Landry Breuil.\n * All rights reserved.\n * Use of this source code is govern"
  },
  {
    "path": "psutil/arch/openbsd/socks.c",
    "chars": 4847,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'.\n * All rights reserved.\n * Use of this source code is governed by a BSD-sty"
  },
  {
    "path": "psutil/arch/openbsd/users.c",
    "chars": 1794,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'.\n * All rights reserved.\n * Use of this source code is governed by a BSD-sty"
  },
  {
    "path": "psutil/arch/osx/cpu.c",
    "chars": 9558,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/osx/disk.c",
    "chars": 12062,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/osx/heap.c",
    "chars": 2690,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/osx/init.c",
    "chars": 996,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/osx/init.h",
    "chars": 2704,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/osx/mem.c",
    "chars": 4295,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/osx/net.c",
    "chars": 3490,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/osx/pids.c",
    "chars": 1224,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/osx/proc.c",
    "chars": 32932,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/osx/proc_utils.c",
    "chars": 6822,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/osx/sensors.c",
    "chars": 3708,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/osx/sys.c",
    "chars": 848,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/posix/init.c",
    "chars": 5770,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/posix/init.h",
    "chars": 2183,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/posix/net.c",
    "chars": 18158,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/posix/pids.c",
    "chars": 1408,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/posix/proc.c",
    "chars": 2339,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/posix/sysctl.c",
    "chars": 6261,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/posix/users.c",
    "chars": 2402,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/sunos/cpu.c",
    "chars": 3257,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/sunos/disk.c",
    "chars": 3031,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/sunos/environ.c",
    "chars": 9939,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola', Oleksii Shevchuk.\n * All rights reserved. Use of this source code is govern"
  },
  {
    "path": "psutil/arch/sunos/init.h",
    "chars": 1840,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/sunos/mem.c",
    "chars": 2928,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/sunos/net.c",
    "chars": 17641,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/sunos/proc.c",
    "chars": 15583,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/sunos/sys.c",
    "chars": 839,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/cpu.c",
    "chars": 11247,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/disk.c",
    "chars": 12115,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/heap.c",
    "chars": 3349,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/init.c",
    "chars": 9476,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/init.h",
    "chars": 6239,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/mem.c",
    "chars": 3615,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/windows/net.c",
    "chars": 13688,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/ntextapi.h",
    "chars": 22963,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/windows/pids.c",
    "chars": 1189,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/windows/proc.c",
    "chars": 34044,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/proc_handles.c",
    "chars": 7835,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/proc_info.c",
    "chars": 26902,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/windows/proc_utils.c",
    "chars": 4108,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/windows/security.c",
    "chars": 3566,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/windows/sensors.c",
    "chars": 927,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/windows/services.c",
    "chars": 13836,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/socks.c",
    "chars": 13855,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "psutil/arch/windows/sys.c",
    "chars": 5800,
    "preview": "/*\n * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a"
  },
  {
    "path": "psutil/arch/windows/wmi.c",
    "chars": 4155,
    "preview": "/*\n * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n * Use of this source code is governed by a BSD-style "
  },
  {
    "path": "pyproject.toml",
    "chars": 9388,
    "preview": "[tool.black]\ntarget-version = [\"py37\"]\nline-length = 79\nskip-string-normalization = true\n# https://black.readthedocs.io/"
  },
  {
    "path": "scripts/battery.py",
    "chars": 1121,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/cpu_distribution.py",
    "chars": 3884,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/disk_usage.py",
    "chars": 1632,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/fans.py",
    "chars": 732,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/free.py",
    "chars": 1238,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/ifconfig.py",
    "chars": 3603,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/internal/README",
    "chars": 105,
    "preview": "This directory contains scripts which are meant to be used internally\n(benchmarks, CI automation, etc.).\n"
  },
  {
    "path": "scripts/internal/bench_oneshot.py",
    "chars": 3257,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/internal/bench_oneshot_2.py",
    "chars": 1074,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/internal/convert_readme.py",
    "chars": 1523,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/internal/download_wheels.py",
    "chars": 2796,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.\n# Use of this source code is govern"
  },
  {
    "path": "scripts/internal/find_adopters.py",
    "chars": 23920,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/internal/find_broken_links.py",
    "chars": 7671,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola', Himanshu Shekhar.\n# All rights reserved. Use of this so"
  },
  {
    "path": "scripts/internal/generate_manifest.py",
    "chars": 918,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.\n# Use of this source code is govern"
  },
  {
    "path": "scripts/internal/git_pre_commit.py",
    "chars": 2964,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.\n# Use of this source code is govern"
  },
  {
    "path": "scripts/internal/install-sysdeps.sh",
    "chars": 2221,
    "preview": "#!/bin/sh\n\n# Depending on the UNIX platform, install the necessary system dependencies to:\n# * compile psutil\n# * run th"
  },
  {
    "path": "scripts/internal/install_pip.py",
    "chars": 1135,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/internal/print_access_denied.py",
    "chars": 3219,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/internal/print_announce.py",
    "chars": 3876,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.\n# Use of this source code is govern"
  },
  {
    "path": "scripts/internal/print_api_speed.py",
    "chars": 6677,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/internal/print_dist.py",
    "chars": 3979,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.\n# Use of this source code is govern"
  },
  {
    "path": "scripts/internal/print_downloads.py",
    "chars": 4027,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.\n# Use of this source code is govern"
  },
  {
    "path": "scripts/internal/print_hashes.py",
    "chars": 1131,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.\n# Use of this source code is govern"
  },
  {
    "path": "scripts/internal/print_sysinfo.py",
    "chars": 4086,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  },
  {
    "path": "scripts/internal/purge_installation.py",
    "chars": 2426,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.\n# Use of this source code is govern"
  },
  {
    "path": "scripts/internal/rst_check_dead_refs.py",
    "chars": 4286,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola. All rights reserved.\n# Use of this source code is govern"
  },
  {
    "path": "scripts/iotop.py",
    "chars": 5065,
    "preview": "#!/usr/bin/env python3\n\n# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.\n# Use of this source code is gover"
  }
]

// ... and 38 more files (download for full content)

About this extraction

This page contains the full source code of the giampaolo/psutil GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 238 files (2.1 MB), approximately 548.6k tokens, and a symbol index with 2269 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!