Full Code of python-trio/trio for AI

main 370c2e5c03f6 cached
219 files
2.2 MB
579.4k tokens
2206 symbols
1 requests
Download .txt
Showing preview only (2,314K chars total). Download the full file or copy to clipboard to get everything.
Repository: python-trio/trio
Branch: main
Commit: 370c2e5c03f6
Files: 219
Total size: 2.2 MB

Directory structure:
gitextract_o0e72cdj/

├── .builds/
│   ├── alpine.yml
│   ├── fedora.yml
│   └── freebsd.yml
├── .codecov.yml
├── .git-blame-ignore-revs
├── .gitattributes
├── .github/
│   └── workflows/
│       ├── autodeps.yml
│       ├── check-newsfragment.yml
│       ├── ci.yml
│       └── release.yml
├── .gitignore
├── .pre-commit-config.yaml
├── .readthedocs.yml
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── LICENSE.APACHE2
├── LICENSE.MIT
├── MANIFEST.in
├── README.rst
├── ci.sh
├── docs/
│   ├── Makefile
│   ├── make.bat
│   ├── notes.txt
│   └── source/
│       ├── _static/
│       │   ├── .gitkeep
│       │   └── styles.css
│       ├── _templates/
│       │   ├── .gitkeep
│       │   ├── genindex.html
│       │   └── layout.html
│       ├── awesome-trio-libraries.rst
│       ├── code-of-conduct.rst
│       ├── conf.py
│       ├── contributing.rst
│       ├── design.rst
│       ├── glossary.rst
│       ├── history.rst
│       ├── index.rst
│       ├── local_customization.py
│       ├── reference-core/
│       │   ├── channels-backpressure.py
│       │   ├── channels-mpmc-broken.py
│       │   ├── channels-mpmc-fixed.py
│       │   ├── channels-shutdown.py
│       │   ├── channels-simple.py
│       │   ├── contextvar-example.py
│       │   ├── from-thread-example.py
│       │   └── thread-contextvars-example.py
│       ├── reference-core.rst
│       ├── reference-io.rst
│       ├── reference-lowlevel.rst
│       ├── reference-testing/
│       │   ├── across-realtime.out
│       │   └── across-realtime.py
│       ├── reference-testing.rst
│       ├── releasing.rst
│       ├── tutorial/
│       │   ├── echo-client.py
│       │   ├── echo-server.py
│       │   ├── tasks-intro.py
│       │   └── tasks-with-trace.py
│       ├── tutorial.rst
│       └── typevars.py
├── docs-requirements.in
├── docs-requirements.txt
├── newsfragments/
│   ├── .gitkeep
│   ├── 3261.bugfix.rst
│   └── README.rst
├── pyproject.toml
├── src/
│   └── trio/
│       ├── __init__.py
│       ├── __main__.py
│       ├── _abc.py
│       ├── _channel.py
│       ├── _core/
│       │   ├── __init__.py
│       │   ├── _asyncgens.py
│       │   ├── _concat_tb.py
│       │   ├── _entry_queue.py
│       │   ├── _exceptions.py
│       │   ├── _generated_instrumentation.py
│       │   ├── _generated_io_epoll.py
│       │   ├── _generated_io_kqueue.py
│       │   ├── _generated_io_windows.py
│       │   ├── _generated_run.py
│       │   ├── _generated_windows_ffi.py
│       │   ├── _instrumentation.py
│       │   ├── _io_common.py
│       │   ├── _io_epoll.py
│       │   ├── _io_kqueue.py
│       │   ├── _io_windows.py
│       │   ├── _ki.py
│       │   ├── _local.py
│       │   ├── _mock_clock.py
│       │   ├── _parking_lot.py
│       │   ├── _run.py
│       │   ├── _run_context.py
│       │   ├── _tests/
│       │   │   ├── __init__.py
│       │   │   ├── test_asyncgen.py
│       │   │   ├── test_cancelled.py
│       │   │   ├── test_exceptiongroup_gc.py
│       │   │   ├── test_guest_mode.py
│       │   │   ├── test_instrumentation.py
│       │   │   ├── test_io.py
│       │   │   ├── test_ki.py
│       │   │   ├── test_local.py
│       │   │   ├── test_mock_clock.py
│       │   │   ├── test_parking_lot.py
│       │   │   ├── test_run.py
│       │   │   ├── test_thread_cache.py
│       │   │   ├── test_tutil.py
│       │   │   ├── test_unbounded_queue.py
│       │   │   ├── test_windows.py
│       │   │   ├── tutil.py
│       │   │   └── type_tests/
│       │   │       ├── nursery_start.py
│       │   │       └── run.py
│       │   ├── _thread_cache.py
│       │   ├── _traps.py
│       │   ├── _unbounded_queue.py
│       │   ├── _wakeup_socketpair.py
│       │   └── _windows_cffi.py
│       ├── _deprecate.py
│       ├── _dtls.py
│       ├── _file_io.py
│       ├── _highlevel_generic.py
│       ├── _highlevel_open_tcp_listeners.py
│       ├── _highlevel_open_tcp_stream.py
│       ├── _highlevel_open_unix_stream.py
│       ├── _highlevel_serve_listeners.py
│       ├── _highlevel_socket.py
│       ├── _highlevel_ssl_helpers.py
│       ├── _path.py
│       ├── _repl.py
│       ├── _signals.py
│       ├── _socket.py
│       ├── _ssl.py
│       ├── _subprocess.py
│       ├── _subprocess_platform/
│       │   ├── __init__.py
│       │   ├── kqueue.py
│       │   ├── waitid.py
│       │   └── windows.py
│       ├── _sync.py
│       ├── _tests/
│       │   ├── __init__.py
│       │   ├── _check_type_completeness.json
│       │   ├── astrill-codesigning-cert.cer
│       │   ├── check_type_completeness.py
│       │   ├── module_with_deprecations.py
│       │   ├── pytest_plugin.py
│       │   ├── test_abc.py
│       │   ├── test_channel.py
│       │   ├── test_contextvars.py
│       │   ├── test_deprecate.py
│       │   ├── test_deprecate_strict_exception_groups_false.py
│       │   ├── test_dtls.py
│       │   ├── test_exports.py
│       │   ├── test_fakenet.py
│       │   ├── test_file_io.py
│       │   ├── test_highlevel_generic.py
│       │   ├── test_highlevel_open_tcp_listeners.py
│       │   ├── test_highlevel_open_tcp_stream.py
│       │   ├── test_highlevel_open_unix_stream.py
│       │   ├── test_highlevel_serve_listeners.py
│       │   ├── test_highlevel_socket.py
│       │   ├── test_highlevel_ssl_helpers.py
│       │   ├── test_path.py
│       │   ├── test_repl.py
│       │   ├── test_scheduler_determinism.py
│       │   ├── test_signals.py
│       │   ├── test_socket.py
│       │   ├── test_ssl.py
│       │   ├── test_subprocess.py
│       │   ├── test_sync.py
│       │   ├── test_testing.py
│       │   ├── test_testing_raisesgroup.py
│       │   ├── test_threads.py
│       │   ├── test_timeouts.py
│       │   ├── test_tracing.py
│       │   ├── test_trio.py
│       │   ├── test_unix_pipes.py
│       │   ├── test_util.py
│       │   ├── test_wait_for_object.py
│       │   ├── test_windows_pipes.py
│       │   ├── tools/
│       │   │   ├── __init__.py
│       │   │   ├── test_gen_exports.py
│       │   │   ├── test_mypy_annotate.py
│       │   │   └── test_sync_requirements.py
│       │   └── type_tests/
│       │       ├── check_wraps.py
│       │       ├── open_memory_channel.py
│       │       ├── path.py
│       │       ├── subprocesses.py
│       │       └── task_status.py
│       ├── _threads.py
│       ├── _timeouts.py
│       ├── _tools/
│       │   ├── __init__.py
│       │   ├── gen_exports.py
│       │   ├── mypy_annotate.py
│       │   ├── sync_requirements.py
│       │   └── windows_ffi_build.py
│       ├── _unix_pipes.py
│       ├── _util.py
│       ├── _version.py
│       ├── _wait_for_object.py
│       ├── _windows_pipes.py
│       ├── abc.py
│       ├── from_thread.py
│       ├── lowlevel.py
│       ├── py.typed
│       ├── socket.py
│       ├── testing/
│       │   ├── __init__.py
│       │   ├── _check_streams.py
│       │   ├── _checkpoints.py
│       │   ├── _fake_net.py
│       │   ├── _memory_streams.py
│       │   ├── _network.py
│       │   ├── _raises_group.py
│       │   ├── _sequencer.py
│       │   └── _trio_test.py
│       └── to_thread.py
├── test-requirements.in
├── test-requirements.txt
├── tests/
│   ├── _trio_check_attrs_aliases.py
│   └── cython/
│       ├── run_test_cython.py
│       └── test_cython.pyx
├── tox.ini
└── zizmor.yml

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

================================================
FILE: .builds/alpine.yml
================================================
image: alpine/latest
packages:
  - curl
  - gcc
  - libffi-dev
  - musl-dev
  - openssl-dev
  - python3-dev
  # required to build cryptography
  - rust
  - cargo
sources:
  - https://github.com/python-trio/trio
tasks:
  - test: |
      python3 -m venv venv
      source venv/bin/activate
      cd trio
      CI_BUILD_ID=$JOB_ID CI_BUILD_URL=$JOB_URL ./ci.sh
environment:
  CODECOV_TOKEN: 87cefb17-c44b-4f2f-8b30-1fff5769ce46
  JOB_NAME: Alpine


================================================
FILE: .builds/fedora.yml
================================================
image: fedora/rawhide
packages:
  - python3-devel
  - python3-pip
sources:
  - https://github.com/python-trio/trio
tasks:
  - test: |
      python3 -m venv venv
      source venv/bin/activate
      cd trio
      CI_BUILD_ID=$JOB_ID CI_BUILD_URL=$JOB_URL ./ci.sh
environment:
  CODECOV_TOKEN: 87cefb17-c44b-4f2f-8b30-1fff5769ce46
  JOB_NAME: Fedora


================================================
FILE: .builds/freebsd.yml
================================================
image: freebsd/latest
packages:
  - curl
  - python39
  - py39-sqlite3
  - rust  # required to build cryptography
sources:
  - https://github.com/python-trio/trio
tasks:
  - setup: sudo ln -s /usr/local/bin/bash /bin/bash
  - test: |
      python3.9 -m venv venv
      source venv/bin/activate
      cd trio
      CI_BUILD_ID=$JOB_ID CI_BUILD_URL=$JOB_URL ./ci.sh
environment:
  CODECOV_TOKEN: 87cefb17-c44b-4f2f-8b30-1fff5769ce46
  JOB_NAME: FreeBSD


================================================
FILE: .codecov.yml
================================================
# -- repository yaml --

# Explicitly wait for all jobs to finish, as wait_for_ci prematurely triggers.
# See https://github.com/python-trio/trio/issues/2689
codecov:
  notify:
    # This number needs to be changed whenever the number of runs in CI is changed.
    # Another option is codecov-cli: https://github.com/codecov/codecov-cli#send-notifications
    after_n_builds: 31
    wait_for_ci: false
    notify_error: true # if uploads fail, replace cov comment with a comment with errors.
  require_ci_to_pass: false

  # Publicly exposing the token has some small risks from mistakes or malicious actors.
  # See https://docs.codecov.com/docs/codecov-tokens for correctly configuring it.
  token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46

# only post PR comment if coverage changes
comment:
  require_changes: true

coverage:
  # required range
  precision: 5
  round: down
  range: 100..100
  status:
    project:
      default:
        target: 100%
    patch:
      default:
        target: 100%  # require patches to be 100%


================================================
FILE: .git-blame-ignore-revs
================================================
# sorting all imports with isort
933f77b96f0092e1baab4474a9208fc2e379aa32
# enabling ruff's flake8-commas rule
b25c02a94e2defcb0fad32976b02218be1133bdf


================================================
FILE: .gitattributes
================================================
# For files generated by trio/_tools/gen_exports.py or trio/_tools/windows_ffi_build.py
trio/_core/_generated*    linguist-generated=true
# Treat generated files as binary in git diff
trio/_core/_generated*    -diff


================================================
FILE: .github/workflows/autodeps.yml
================================================
name: Autodeps

on:
  workflow_dispatch:
  schedule:
    - cron:  '0 0 1 * *'

jobs:
  Autodeps:
    if: github.repository_owner == 'python-trio'
    name: Autodeps
    timeout-minutes: 10
    runs-on: 'ubuntu-latest'
    # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#changing-github_token-permissions
    permissions:
      pull-requests: write
      issues: write
      repository-projects: write
      contents: write

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          persist-credentials: true  # credentials are needed to push commits
      - name: Setup python
        uses: actions/setup-python@v5
        with:
          python-version: "3.10"

      - name: Bump dependencies
        run: |
          python -m pip install -U pip pre-commit
          python -m pip install -r test-requirements.txt
          uv pip compile --universal --python-version=3.10 --upgrade test-requirements.in -o test-requirements.txt
          uv pip compile --universal --python-version=3.11 --upgrade docs-requirements.in -o docs-requirements.txt
          pre-commit autoupdate --jobs 0

      - name: Install new requirements
        run: python -m pip install -r test-requirements.txt

      - name: Pre-commit fixes
        run: pre-commit run -a || true

      - name: Commit changes and create automerge PR
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          # setup git repo
          git switch --force-create autodeps/bump_from_${GITHUB_SHA:0:6}
          git config user.name 'github-actions[bot]'
          git config user.email '41898282+github-actions[bot]@users.noreply.github.com'

          if ! git commit -am "Dependency updates"; then
            echo "No changes to commit!"
            exit 0
          fi

          git push --force --set-upstream origin autodeps/bump_from_${GITHUB_SHA:0:6}

          # git push returns before github is ready for a pr, so we poll until success
          for BACKOFF in 1 2 4 8 0; do
            sleep $BACKOFF
            if gh pr create \
              --label dependencies --body "" \
              --title "Bump dependencies from commit ${GITHUB_SHA:0:6}" \
              ; then
              break
            fi
          done

          if [ $BACKOFF -eq 0 ]; then
            echo "Could not create the PR"
            exit 1
          fi

          # gh pr create returns before the pr is ready, so we again poll until success
          # https://github.com/cli/cli/issues/2619#issuecomment-1240543096
          for BACKOFF in 1 2 4 8 0; do
            sleep $BACKOFF
            if gh pr merge --auto --squash; then
              break
            fi
          done

          if [ $BACKOFF -eq 0 ]; then
            echo "Could not set automerge"
            exit 1
          fi


================================================
FILE: .github/workflows/check-newsfragment.yml
================================================
name: Check newsfragment

permissions: {}

on:
  pull_request:
    types: [labeled, unlabeled, opened, synchronize]
    branches:
    - main

jobs:
  check-newsfragment:
    if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip newsfragment') }}
    runs-on: 'ubuntu-latest'

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          persist-credentials: false

      - name: Check newsfragments
        run: |
          if git diff --name-only origin/main | grep -v '/_tests/' | grep 'src/trio/'; then
            git diff --name-only origin/main | grep 'newsfragments/' || exit 1
          fi


================================================
FILE: .github/workflows/ci.yml
================================================
name: CI

permissions: {}

on:
  push:
    branches-ignore:
      # these branches always have another event associated
      - gh-readonly-queue/**        # GitHub's merge queue uses `merge_group`
      - autodeps/**                 # autodeps always makes a PR
      - pre-commit-ci-update-config # pre-commit.ci's updates always have a PR
  pull_request:
  merge_group:

concurrency:
  group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && format('-{0}', github.sha) || '' }}
  cancel-in-progress: true

env:
  dists-artifact-name: python-package-distributions
  dist-name: trio

jobs:
  build:
    name: 👷 dists

    runs-on: ubuntu-latest

    outputs:
      dist-version: ${{ steps.dist-version.outputs.version }}
      sdist-artifact-name: ${{ steps.artifact-name.outputs.sdist }}
      wheel-artifact-name: ${{ steps.artifact-name.outputs.wheel }}

    steps:
      - name: Switch to using Python 3.11
        uses: actions/setup-python@v6
        with:
          python-version: 3.11

      - name: Grab the source from Git
        uses: actions/checkout@v5
        with:
          persist-credentials: false

      - name: Get the dist version
        id: dist-version
        run: >-
          echo "version=$(
          grep ^__version__ src/trio/_version.py
          | sed 's#__version__ = "\([^"]\+\)"#\1#'
          )"
          >> "${GITHUB_OUTPUT}"

      - name: Set the expected dist artifact names
        id: artifact-name
        run: |
          echo "sdist=${DIST_NAME}-${VERSION}.tar.gz" >> "${GITHUB_OUTPUT}"
          echo "wheel=${DIST_NAME}-${VERSION}-py3-none-any.whl" >> "${GITHUB_OUTPUT}"
        env:
          DIST_NAME: ${{ env.dist-name }}
          VERSION: ${{ steps.dist-version.outputs.version }}

      - name: Install build
        run: python -Im pip install build

      - name: Build dists
        run: python -Im build
      - name: Verify that the artifacts with expected names got created
        run: >-
          ls -1
          dist/${SDIST}
          dist/${WHEEL}
        env:
          SDIST: ${{ steps.artifact-name.outputs.sdist }}
          WHEEL: ${{ steps.artifact-name.outputs.wheel }}
      - name: Store the distribution packages
        uses: actions/upload-artifact@v5
        with:
          name: ${{ env.dists-artifact-name }}
          # NOTE: Exact expected file names are specified here
          # NOTE: as a safety measure — if anything weird ends
          # NOTE: up being in this dir or not all dists will be
          # NOTE: produced, this will fail the workflow.
          path: |
            dist/${{ steps.artifact-name.outputs.sdist }}
            dist/${{ steps.artifact-name.outputs.wheel }}
          retention-days: 5

  smoke-tests:
    name: Smoke tests
    needs:
      - build

    runs-on: ubuntu-latest

    steps:
      - name: Switch to using Python 3.11
        uses: actions/setup-python@v6
        with:
          python-version: 3.11

      - name: >-
          Smoke-test:
          retrieve the project source from an sdist inside the GHA artifact
        uses: re-actors/checkout-python-sdist@release/v2
        with:
          source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
          workflow-artifact-name: ${{ env.dists-artifact-name }}

      - name: >-
          Smoke-test: move the sdist-retrieved dir into sdist-src
        run: |
          mv -v '${{ github.workspace }}' '${{ runner.temp }}/sdist-src'
          mkdir -pv '${{ github.workspace }}'
          mv -v '${{ runner.temp }}/sdist-src' '${{ github.workspace }}/sdist-src'
        shell: bash -eEuo pipefail {0}

      - name: >-
          Smoke-test: grab the source from Git into git-src
        uses: actions/checkout@v5
        with:
          path: git-src
          persist-credentials: false

      - name: >-
          Smoke-test: install test requirements from the Git repo
        run: >-
          python -Im
          pip install -c test-requirements.txt -r test-requirements.txt
        shell: bash -eEuo pipefail {0}
        working-directory: git-src

      - name: >-
          Smoke-test: collect tests from the Git repo
        env:
          PYTHONPATH: src/
        run: >-
          pytest --collect-only -qq .
          | sort
          | tee collected-tests
        shell: bash -eEuo pipefail {0}
        working-directory: git-src

      - name: >-
          Smoke-test: collect tests from the sdist tarball
        env:
          PYTHONPATH: src/
        run: >-
          pytest --collect-only -qq .
          | sort
          | tee collected-tests
        shell: bash -eEuo pipefail {0}
        working-directory: sdist-src

      - name: >-
          Smoke-test:
          verify that all the tests from Git are included in the sdist
        run: diff --unified sdist-src/collected-tests git-src/collected-tests
        shell: bash -eEuo pipefail {0}

  Windows:
    name: 'Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})'
    needs:
      - build

    timeout-minutes: 20
    runs-on: 'windows-latest'
    strategy:
      fail-fast: false
      matrix:
        python: ['3.10', '3.11', '3.12', '3.13', '3.14', '3.14t']
        arch: ['x86', 'x64']
        lsp: ['']
        lsp_extract_file: ['']
        extra_name: ['']
        include:
          - python: '3.10'
            arch: 'x64'
            lsp: 'https://raw.githubusercontent.com/python-trio/trio-ci-assets/master/komodia-based-vpn-setup.zip'
            lsp_extract_file: 'komodia-based-vpn-setup.exe'
            extra_name: ', with Komodia LSP'
          - python: '3.10'
            arch: 'x64'
            lsp: 'https://www.proxifier.com/download/legacy/ProxifierSetup342.exe'
            lsp_extract_file: ''
            extra_name: ', with IFS LSP'
          - python: 'pypy-3.11'
            arch: 'x64'
            lsp: ''
            lsp_extract_file: ''
            extra_name: ''
          #- python: '3.10'
          #  arch: 'x64'
          #  lsp: 'http://download.pctools.com/mirror/updates/9.0.0.2308-SDavfree-lite_en.exe'
          #  lsp_extract_file: ''
          #  extra_name: ', with non-IFS LSP'

    continue-on-error: >-
      ${{
        (
          endsWith(matrix.python, '-dev')
          || endsWith(matrix.python, '-nightly')
        )
        && true
        || false
      }}
    steps:
      - name: Retrieve the project source from an sdist inside the GHA artifact
        uses: re-actors/checkout-python-sdist@release/v2
        with:
          source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
          workflow-artifact-name: ${{ env.dists-artifact-name }}
      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: '${{ matrix.python }}'
          architecture: '${{ matrix.arch }}'
          allow-prereleases: true
      - name: Run tests
        run: ./ci.sh
        shell: bash
        env:
          LSP: '${{ matrix.lsp }}'
          LSP_EXTRACT_FILE: '${{ matrix.lsp_extract_file }}'
      - if: always()
        uses: codecov/codecov-action@v5
        with:
          name: Windows (${{ matrix.python }}, ${{ matrix.arch }}${{ matrix.extra_name }})
          # multiple flags is marked as an error in codecov UI, but is actually fine
          # https://github.com/codecov/feedback/issues/567
          flags: Windows,${{ matrix.python }}
          fail_ci_if_error: true

  Ubuntu:
    name: 'Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})'
    needs:
      - build

    timeout-minutes: 10
    runs-on: 'ubuntu-latest'
    strategy:
      fail-fast: false
      matrix:
        python: ['pypy-3.11', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t']
        check_formatting: ['0']
        no_test_requirements: ['0']
        extra_name: ['']
        include:
          - python: '3.13'
            check_formatting: '1'
            extra_name: ', check formatting'
          # separate test run that doesn't install test-requirements.txt
          - python: '3.10'
            no_test_requirements: '1'
            extra_name: ', no test-requirements'
    continue-on-error: >-
      ${{
        (
          endsWith(matrix.python, '-dev')
          || endsWith(matrix.python, '-nightly')
        )
        && true
        || false
      }}
    steps:
      - name: Retrieve the project source from an sdist inside the GHA artifact
        if: matrix.check_formatting != '1'
        uses: re-actors/checkout-python-sdist@release/v2
        with:
          source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
          workflow-artifact-name: ${{ env.dists-artifact-name }}
      - name: Grab the source from Git
        if: matrix.check_formatting == '1'
        uses: actions/checkout@v4
        with:
          persist-credentials: false
      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: '${{ matrix.python }}'
          cache: pip
          cache-dependency-path: test-requirements.txt
          allow-prereleases: true
      - name: Setup minimum Python version
        if: matrix.check_formatting == '1'
        uses: actions/setup-python@v6
        with:
          python-version: '3.10'
          cache: pip
          cache-dependency-path: test-requirements.txt
          allow-prereleases: true
      - name: Check Formatting
        if: matrix.check_formatting == '1'
        run:
          python -m pip install tox &&
          tox -m check
      - name: Install python3-apport
        if: matrix.check_formatting == '0'
        run: |
          sudo apt update
          sudo apt install -q python3-apport
      - name: Run tests
        if: matrix.check_formatting == '0'
        run: ./ci.sh
        env:
          NO_TEST_REQUIREMENTS: '${{ matrix.no_test_requirements }}'
      - if: >-
          always()
          && matrix.check_formatting != '1'
        uses: codecov/codecov-action@v5
        with:
          name: Ubuntu (${{ matrix.python }}${{ matrix.extra_name }})
          flags: Ubuntu,${{ matrix.python }}
          fail_ci_if_error: true

  macOS:
    name: 'macOS (${{ matrix.python }})'
    needs:
      - build

    timeout-minutes: 15
    runs-on: 'macos-latest'
    strategy:
      fail-fast: false
      matrix:
        python: ['pypy-3.11', '3.10', '3.11', '3.12', '3.13', '3.14', '3.14t']
    continue-on-error: >-
      ${{
        (
          endsWith(matrix.python, '-dev')
          || endsWith(matrix.python, '-nightly')
        )
        && true
        || false
      }}
    steps:
      - name: Retrieve the project source from an sdist inside the GHA artifact
        uses: re-actors/checkout-python-sdist@release/v2
        with:
          source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
          workflow-artifact-name: ${{ env.dists-artifact-name }}
      - name: Setup Python
        uses: actions/setup-python@v6
        with:
          python-version: '${{ matrix.python }}'
          cache: pip
          cache-dependency-path: test-requirements.txt
          allow-prereleases: true
      - name: Run tests
        run: ./ci.sh
      - if: always()
        uses: codecov/codecov-action@v5
        with:
          name: macOS (${{ matrix.python }})
          flags: macOS,${{ matrix.python }}
          fail_ci_if_error: true

  # run CI on a musl linux
  Alpine:
    name: "Alpine"
    needs:
      - build

    runs-on: ubuntu-latest
    container: alpine
    steps:
      - name: Install necessary packages
        # can't use setup-python because that python doesn't seem to work;
        # `python3-dev` (rather than `python:alpine`) for some ctypes reason,
        # `curl`, `gpg`, `git` for codecov-action v4/v5 to work (https://github.com/codecov/codecov-action/issues/1320).
        # `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test).
        # `perl` for a platform independent `sed -i` alternative
        run: apk update && apk add python3-dev bash curl gpg git nodejs perl

      - name: Retrieve the project source from an sdist inside the GHA artifact
        # must be after `apk add` because it relies on `bash` existing
        uses: re-actors/checkout-python-sdist@release/v2
        with:
          source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
          workflow-artifact-name: ${{ env.dists-artifact-name }}

      - name: Enter virtual environment
        run: python -m venv .venv

      - name: Run tests
        run: source .venv/bin/activate && ./ci.sh

      - name: Get Python version for codecov flag
        id: get-version
        shell: python
        run: |
          import sys, os
          with open(os.environ["GITHUB_OUTPUT"], "a") as f:
            f.write("version=" + ".".join(map(str, sys.version_info[:2])))
            f.write("\n")

      - if: always()
        uses: codecov/codecov-action@v5
        with:
          name: Alpine
          flags: Alpine,${{ steps.get-version.outputs.version }}
          fail_ci_if_error: true

  Cython:
    name: "Cython"
    needs:
      - build

    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          # Cython 2 supports 3.10 and 3.11 and Cython 3 supports all versions we do,
          # so test both the lowest and higher version for both
          - python: '3.10'
            cython: '<3'
          - python: '3.11'
            cython: '<3'
          # TODO: technically we should pin cython versions
          - python: '3.10'
            cython: '>=3'
          - python: '3.14'
            cython: '>=3'
    steps:
      - name: Retrieve the project source from an sdist inside the GHA artifact
        uses: re-actors/checkout-python-sdist@release/v2
        with:
          source-tarball-name: ${{ needs.build.outputs.sdist-artifact-name }}
          workflow-artifact-name: ${{ env.dists-artifact-name }}
      - name: Setup Python
        uses: actions/setup-python@v6
        with:
            python-version: '${{ matrix.python }}'
            cache: pip
        # setuptools is needed to get distutils on 3.12, which cythonize requires
      - name: install trio and setuptools
        run: python -m pip install --upgrade pip . setuptools 'coverage[toml]'

      - name: add cython plugin to the coveragepy config
        run: >-
          sed -i 's#plugins\s=\s\[\]#plugins = ["Cython.Coverage"]#'
          pyproject.toml

      - name: install cython & compile pyx file
        env:
          CFLAGS: ${{ env.CFLAGS }} -DCYTHON_TRACE_NOGIL=1
        run: |
          python -m pip install "cython${{ matrix.cython }}"
          cythonize --inplace -X linetrace=True tests/cython/test_cython.pyx

      - name: import & run module
        run: coverage run -m tests.cython.run_test_cython

      - name: Get Python version for codecov flag
        id: get-version
        shell: python
        run: |
          import sys, os
          with open(os.environ["GITHUB_OUTPUT"], "a") as f:
            f.write("version=" + ".".join(map(str, sys.version_info[:2])))
            f.write("\n")

      - run: |
          coverage combine
          coverage report

      - if: always()
        uses: codecov/codecov-action@v5
        with:
          name: Cython
          flags: Cython,${{ steps.get-version.outputs.version }}
          fail_ci_if_error: true

  # https://github.com/marketplace/actions/alls-green#why
  check:  # This job does nothing and is only used for the branch protection

    if: always()

    needs:
      - smoke-tests
      - Windows
      - Ubuntu
      - macOS
      - Alpine
      - Cython

    runs-on: ubuntu-latest

    steps:
      - name: Decide whether the needed jobs succeeded or failed
        uses: re-actors/alls-green@release/v1
        with:
          jobs: ${{ toJSON(needs) }}


================================================
FILE: .github/workflows/release.yml
================================================
on:
  push:
    tags:
      - v*

permissions: {}

# a lot of code taken from https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false
      - uses: actions/setup-python@v5
        with:
          python-version: "3.10"
      - run: python -m pip install build
      - run: python -m build

      - uses: actions/upload-artifact@v4
        with:
          name: trio-dist
          path: |
            dist/*.tar.gz
            dist/*.whl

  pypi-publish:
    needs: [build]
    name: upload release to PyPI
    runs-on: ubuntu-latest
    environment:
      name: release
      url: https://pypi.org/project/trio
    permissions:
      id-token: write

    steps:
      - uses: actions/download-artifact@v4
        with:
          pattern: trio-*
          path: dist
          merge-multiple: true

      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1


================================================
FILE: .gitignore
================================================
# generated by cythonize
tests/cython/test_cython.c

# In case somebody wants to restore the directory for local testing
notes-to-self/

# Project-specific generated files
docs/build/

bench/results/
bench/env/
bench/trio/

# Byte-compiled / optimized / DLL files / editor temp files
__pycache__/
*.py[cod]
*~
\#*
.#*
*.swp

# C extensions
*.so

# Distribution / packaging
.Python
/build/
/develop-eggs/
/dist/
/eggs/
/lib/
/lib64/
/parts/
/sdist/
/var/
*.egg-info/
.installed.cfg
*.egg
/.pybuild
pip-wheel-metadata/

# Installer logs
pip-log.txt

# Unit test / coverage reports
htmlcov/
.tox/
.venv/
pyvenv.cfg
.coverage
.coverage.*
.cache
.pytest_cache/
.mypy_cache/
nosetests.xml
coverage.xml

# Temp file during Mypy processing
mypy_annotate.dat

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Django stuff:
*.log
*.pot

# Sphinx documentation
doc/_build/

# PyCharm
.idea/


================================================
FILE: .pre-commit-config.yaml
================================================
ci:
  autofix_prs: true
  autoupdate_schedule: weekly
  submodules: false
  # pip-compile requires internet, regenerate-files may get cache
  # issues in CI, so they're run in check.sh
  skip: [pip-compile, regenerate-files]

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-toml
      - id: check-merge-conflict
      - id: mixed-line-ending
      - id: check-case-conflict
      - id: sort-simple-yaml
        files: .pre-commit-config.yaml
  - repo: https://github.com/psf/black-pre-commit-mirror
    rev: 26.3.1
    hooks:
      - id: black
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.15.6
    hooks:
      - id: ruff-check
        types: [file]
        types_or: [python, pyi, toml]
        args: ["--show-fixes"]
  - repo: https://github.com/codespell-project/codespell
    rev: v2.4.2
    hooks:
      - id: codespell
        additional_dependencies:
          # tomli needed on 3.10. tomllib is available in stdlib on 3.11+
          - tomli
  - repo: https://github.com/adhtruong/mirrors-typos
    rev: v1.44.0
    hooks:
      - id: typos
  - repo: https://github.com/sphinx-contrib/sphinx-lint
    rev: v1.0.2
    hooks:
      - id: sphinx-lint
  - repo: https://github.com/woodruffw/zizmor-pre-commit
    rev: v1.23.1
    hooks:
      - id: zizmor
  - repo: local
    hooks:
      - id: regenerate-files
        name: regenerate generated files
        language: python
        entry: python src/trio/_tools/gen_exports.py
        pass_filenames: false
        additional_dependencies: ["astor", "attrs", "black", "ruff"]
        files: ^src\/trio\/_core\/(_run|(_i(o_(common|epoll|kqueue|windows)|nstrumentation)))\.py$
      - id: regenerate-windows-cffi
        name: regenerate windows CFFI
        language: python
        entry: python src/trio/_tools/windows_ffi_build.py
        pass_filenames: false
        additional_dependencies: ["cffi"]
        files: ^src\/trio\/_tools\/windows_ffi_build\.py$
      - id: sync-test-requirements
        name: synchronize test requirements
        language: python
        entry: python src/trio/_tools/sync_requirements.py
        pass_filenames: false
        additional_dependencies: ["pyyaml"]
        files: ^(test-requirements\.txt)|(\.pre-commit-config\.yaml)$
  - repo: https://github.com/astral-sh/uv-pre-commit
    rev: 0.10.11
    hooks:
      # Compile requirements
      - id: pip-compile
        name: uv pip-compile test-requirements.in
        args: [
          "--universal",
          "--python-version=3.10",
          "test-requirements.in",
          "-o",
          "test-requirements.txt"]
        files: ^test-requirements\.(in|txt)$
      - id: pip-compile
        name: uv pip-compile docs-requirements.in
        args: [
          "--universal",
          "--python-version=3.11",
          "docs-requirements.in",
          "-o",
          "docs-requirements.txt"]
        files: ^docs-requirements\.(in|txt)$


================================================
FILE: .readthedocs.yml
================================================
# https://docs.readthedocs.io/en/latest/config-file/index.html
version: 2

formats:
  - htmlzip
  - epub

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

python:
  install:
    - requirements: docs-requirements.txt
    - path: .

sphinx:
  fail_on_warning: true
  configuration: docs/source/conf.py


================================================
FILE: CODE_OF_CONDUCT.md
================================================
For the Trio code of conduct, see:
    https://trio.readthedocs.io/en/latest/code-of-conduct.html


================================================
FILE: CONTRIBUTING.md
================================================
For the Trio contributing guide, see:
    https://trio.readthedocs.io/en/latest/contributing.html


================================================
FILE: LICENSE
================================================
This software is made available under the terms of *either* of the
licenses found in LICENSE.APACHE2 or LICENSE.MIT. Contributions to
Trio are made under the terms of *both* these licenses.


================================================
FILE: LICENSE.APACHE2
================================================

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


================================================
FILE: LICENSE.MIT
================================================
Copyright Contributors to the Trio project.

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


================================================
FILE: MANIFEST.in
================================================
include .codecov.yml
include check.sh
include ci.sh
include LICENSE LICENSE.MIT LICENSE.APACHE2
include README.rst
include CODE_OF_CONDUCT.md CONTRIBUTING.md
include *-requirements.in
include *-requirements.txt
include src/trio/py.typed
include src/trio/_tests/astrill-codesigning-cert.cer
recursive-include src/trio/_tests/test_ssl_certs *.pem
recursive-include docs *
recursive-include tests *
prune docs/build


================================================
FILE: README.rst
================================================
.. image:: https://img.shields.io/badge/chat-join%20now-blue.svg
   :target: https://gitter.im/python-trio/general
   :alt: Join chatroom

.. image:: https://img.shields.io/badge/forum-join%20now-blue.svg
   :target: https://trio.discourse.group
   :alt: Join forum

.. image:: https://img.shields.io/badge/docs-read%20now-blue.svg
   :target: https://trio.readthedocs.io
   :alt: Documentation

.. image:: https://img.shields.io/pypi/v/trio.svg
   :target: https://pypi.org/project/trio
   :alt: Latest PyPi version

.. image:: https://img.shields.io/conda/vn/conda-forge/trio.svg
   :target: https://anaconda.org/conda-forge/trio
   :alt: Latest conda-forge version

.. image:: https://codecov.io/gh/python-trio/trio/branch/main/graph/badge.svg
   :target: https://codecov.io/gh/python-trio/trio
   :alt: Test coverage

Trio – a friendly Python library for async concurrency and I/O
==============================================================

.. image:: https://raw.githubusercontent.com/python-trio/trio/9b0bec646a31e0d0f67b8b6ecc6939726faf3e17/logo/logo-with-background.svg
   :width: 200px
   :align: right

The Trio project aims to produce a production-quality,
`permissively licensed
<https://github.com/python-trio/trio/blob/main/LICENSE>`__,
async/await-native I/O library for Python. Like all async libraries,
its main purpose is to help you write programs that do **multiple
things at the same time** with **parallelized I/O**. A web spider that
wants to fetch lots of pages in parallel, a web server that needs to
juggle lots of downloads and websocket connections simultaneously, a
process supervisor monitoring multiple subprocesses... that sort of
thing. Compared to other libraries, Trio attempts to distinguish
itself with an obsessive focus on **usability** and
**correctness**. Concurrency is complicated; we try to make it *easy*
to get things *right*.

Trio was built from the ground up to take advantage of the `latest
Python features <https://www.python.org/dev/peps/pep-0492/>`__, and
draws inspiration from `many sources
<https://github.com/python-trio/trio/wiki/Reading-list>`__, in
particular Dave Beazley's `Curio <https://curio.readthedocs.io/>`__.
The resulting design is radically simpler than older competitors like
`asyncio <https://docs.python.org/3/library/asyncio.html>`__ and
`Twisted <https://twistedmatrix.com/>`__, yet just as capable. Trio is
the Python I/O library I always wanted; I find it makes building
I/O-oriented programs easier, less error-prone, and just plain more
fun. `Perhaps you'll find the same
<https://github.com/python-trio/trio/wiki/Testimonials>`__.

Trio is a mature and well-tested project: the overall design is solid,
and the existing features are fully documented and widely used in
production. While we occasionally make minor interface adjustments,
breaking changes are rare. We encourage you to use Trio with confidence,
but if you rely on long-term API stability, consider `subscribing to
issue #1 <https://github.com/python-trio/trio/issues/1>`__ for advance
notice of any compatibility updates.


Where to next?
--------------

**I want to try it out!** Awesome! We have a `friendly tutorial
<https://trio.readthedocs.io/en/stable/tutorial.html>`__ to get you
started; no prior experience with async coding is required.

**Ugh, I don't want to read all that – show me some code!** If you're
impatient, then here's a `simple concurrency example
<https://trio.readthedocs.io/en/stable/tutorial.html#tutorial-example-tasks-intro>`__,
an `echo client
<https://trio.readthedocs.io/en/stable/tutorial.html#tutorial-echo-client-example>`__,
and an `echo server
<https://trio.readthedocs.io/en/stable/tutorial.html#tutorial-echo-server-example>`__.

**How does Trio make programs easier to read and reason about than
competing approaches?** Trio is based on a new way of thinking that we
call "structured concurrency". The best theoretical introduction is
the article `Notes on structured concurrency, or: Go statement
considered harmful
<https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/>`__.
Or, `check out this talk at PyCon 2018
<https://www.youtube.com/watch?v=oLkfnc_UMcE>`__ to see a
demonstration of implementing the "Happy Eyeballs" algorithm in an
older library versus Trio.

**Cool, but will it work on my system?** Probably! As long as you have
some kind of Python 3.10-or-better (CPython or `currently maintained versions of
PyPy3 <https://doc.pypy.org/en/latest/faq.html#which-python-versions-does-pypy-implement>`__
are both fine), and are using Linux, macOS, Windows, or FreeBSD, then Trio
will work. Other environments might work too, but those
are the ones we test on. And all of our dependencies are pure Python,
except for CFFI on Windows, which has wheels available, so
installation should be easy (no C compiler needed).

**I tried it, but it's not working.** Sorry to hear that! You can try
asking for help in our `chat room
<https://gitter.im/python-trio/general>`__ or `forum
<https://trio.discourse.group>`__, `filing a bug
<https://github.com/python-trio/trio/issues/new>`__, or `posting a
question on StackOverflow
<https://stackoverflow.com/questions/ask?tags=python+python-trio>`__,
and we'll do our best to help you out.

**Trio is awesome, and I want to help make it more awesome!** You're
the best! There's tons of work to do – filling in missing
functionality, building up an ecosystem of Trio-using libraries,
usability testing (e.g., maybe try teaching yourself or a friend to
use Trio and make a list of every error message you hit and place
where you got confused?), improving the docs, ... check out our `guide
for contributors
<https://trio.readthedocs.io/en/stable/contributing.html>`__!

**I don't have any immediate plans to use it, but I love geeking out
about I/O library design!** That's a little weird? But let's be
honest, you'll fit in great around here. We have a `whole sub-forum
for discussing structured concurrency
<https://trio.discourse.group/c/structured-concurrency>`__ (developers
of other systems welcome!). Or check out our `discussion of design
choices
<https://trio.readthedocs.io/en/stable/design.html#user-level-api-principles>`__,
`reading list
<https://github.com/python-trio/trio/wiki/Reading-list>`__, and
`issues tagged design-discussion
<https://github.com/python-trio/trio/labels/design%20discussion>`__.

**I want to make sure my company's lawyers won't get angry at me!** No
worries, Trio is permissively licensed under your choice of MIT or
Apache 2. See `LICENSE
<https://github.com/python-trio/trio/blob/main/LICENSE>`__ for details.


Code of conduct
---------------

Contributors are requested to follow our `code of conduct
<https://trio.readthedocs.io/en/stable/code-of-conduct.html>`__ in all
project spaces.


================================================
FILE: ci.sh
================================================
#!/bin/bash

set -ex -o pipefail

# disable warnings about pyright being out of date
# used in test_exports and in check.sh
export PYRIGHT_PYTHON_IGNORE_WARNINGS=1

# Log some general info about the environment
echo "::group::Environment"
uname -a
env | sort
echo "::endgroup::"

# Curl's built-in retry system is not very robust; it gives up on lots of
# network errors that we want to retry on. Wget might work better, but it's
# not installed on azure pipelines's windows boxes. So... let's try some good
# old-fashioned brute force. (This is also a convenient place to put options
# we always want, like -f to tell curl to give an error if the server sends an
# error response, and -L to follow redirects.)
function curl-harder() {
    for BACKOFF in 0 1 2 4 8 15 15 15 15; do
        sleep $BACKOFF
        if curl -fL --connect-timeout 5 "$@"; then
            return 0
        fi
    done
    return 1
}

################################################################
# We have a Python environment!
################################################################

echo "::group::Versions"
python -c "import sys, struct, ssl; print('python:', sys.version); print('version_info:', sys.version_info); print('bits:', struct.calcsize('P') * 8); print('openssl:', ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO)"
echo "::endgroup::"

echo "::group::Install dependencies"
python -m pip install -U pip uv -c test-requirements.txt
python -m pip --version
python -m uv --version

python -m uv pip install build

python -m build
wheel_package=$(ls dist/*.whl)
python -m uv pip install "trio @ $wheel_package" -c test-requirements.txt

# Actual tests
# expands to 0 != 1 if NO_TEST_REQUIREMENTS is not set, if set the `-0` has no effect
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
if [ "${NO_TEST_REQUIREMENTS-0}" == 1 ]; then
    python -m uv pip install pytest coverage -c test-requirements.txt
    flags="--skip-optional-imports"
else
    python -m uv pip install -r test-requirements.txt --no-deps
    flags=""
fi

# If we're testing with a LSP installed, then it might break network
# stuff, so wait until after we've finished setting everything else
# up.
if [ "$LSP" != "" ]; then
    echo "Installing LSP from ${LSP}"
    # We use --insecure because one of the LSP's has been observed to give
    # cert verification errors:
    #
    #   https://github.com/python-trio/trio/issues/1478
    #
    # *Normally*, you should never ever use --insecure, especially when
    # fetching an executable! But *in this case*, we're intentionally
    # installing some untrustworthy quasi-malware onto into a sandboxed
    # machine for testing. So MITM attacks are really the least of our
    # worries.
    if [ "$LSP_EXTRACT_FILE" != "" ]; then
        # We host the Astrill VPN installer ourselves, and encrypt it
        # so as to decrease the chances of becoming an inadvertent
        # public redistributor.
        curl-harder -o lsp-installer.zip "$LSP"
        unzip -P "not very secret trio ci key" lsp-installer.zip "$LSP_EXTRACT_FILE"
        mv "$LSP_EXTRACT_FILE" lsp-installer.exe
    else
        curl-harder --insecure -o lsp-installer.exe "$LSP"
    fi
    # This is only needed for the Astrill LSP, but there's no harm in
    # doing it all the time. The cert was manually extracted by installing
    # the package in a VM, clicking "Always trust from this publisher"
    # when installing, and then running 'certmgr.msc' and exporting the
    # certificate. See:
    #    http://www.migee.com/2010/09/24/solution-for-unattendedsilent-installs-and-would-you-like-to-install-this-device-software/
    certutil -addstore "TrustedPublisher" src/trio/_tests/astrill-codesigning-cert.cer
    # Double-slashes are how you tell windows-bash that you want a single
    # slash, and don't treat this as a unix-style filename that needs to
    # be replaced by a windows-style filename.
    # http://www.mingw.org/wiki/Posix_path_conversion
    ./lsp-installer.exe //silent //norestart
    echo "Waiting for LSP to appear in Winsock catalog"
    while ! netsh winsock show catalog | grep "Layered Chain Entry"; do
        sleep 1
    done
    netsh winsock show catalog
fi
echo "::endgroup::"

echo "::group::Setup for tests"

# We run the tests from inside an empty directory, to make sure Python
# doesn't pick up any .py files from our working dir. Might have already
# been created by a previous run.
mkdir empty || true
cd empty

INSTALLDIR=$(python -c "import os, trio; print(os.path.dirname(trio.__file__))")
cp ../pyproject.toml "$INSTALLDIR"  # TODO: remove this

# get mypy tests a nice cache
MYPYPATH=".." mypy --config-file= --cache-dir=./.mypy_cache -c "import trio" >/dev/null 2>/dev/null || true

# support subprocess spawning with coverage.py
echo "import coverage; coverage.process_startup()" | tee -a "$INSTALLDIR/../sitecustomize.py"

perl -i -pe 's/-p trio\._tests\.pytest_plugin//' "$INSTALLDIR/pyproject.toml"

echo "::endgroup::"
echo "::group:: Run Tests"
if PYTHONPATH=../tests COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml \
        coverage run --rcfile=../pyproject.toml -m \
        pytest -ra --junitxml=../test-results.xml \
        -p _trio_check_attrs_aliases --verbose --durations=10 \
        -p trio._tests.pytest_plugin --run-slow $flags "${INSTALLDIR}"; then
    PASSED=true
else
    PASSED=false
fi
echo "::endgroup::"
echo "::group::Coverage"

coverage combine --rcfile ../pyproject.toml
cd ..  # coverage needs to be in the folder containing src/trio
cp empty/.coverage .
coverage report -m --rcfile ./pyproject.toml
coverage xml --rcfile ./pyproject.toml

# Remove the LSP again; again we want to do this ASAP to avoid
# accidentally breaking other stuff.
if [ "$LSP" != "" ]; then
    netsh winsock reset
fi

echo "::endgroup::"
$PASSED


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

# You can set these variables from the command line.
SPHINXOPTS    =
SPHINXBUILD   = sphinx-build
SPHINXPROJ    = Trio
SOURCEDIR     = source
BUILDDIR      = build

# Put it first so that "make" without argument is like "make help".
help:
	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)


================================================
FILE: docs/make.bat
================================================
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
	set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
set SPHINXPROJ=Trio

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
	echo.
	echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
	echo.installed, then set the SPHINXBUILD environment variable to point
	echo.to the full path of the 'sphinx-build' executable. Alternatively you
	echo.may add the Sphinx directory to PATH.
	echo.
	echo.If you don't have Sphinx installed, grab it from
	echo.http://sphinx-doc.org/
	exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%

:end
popd


================================================
FILE: docs/notes.txt
================================================
it's possible from extension/configuration modules to get sphinx to
know about new roles and even new autodoc types.

See curio docs, which cribbed from the python docs and have a link to
them

and also:

https://github.com/aio-libs/sphinxcontrib-asyncio/pull/1/files

which added autodoc hooks to sphinxcontrib-asyncio


it looks like there's a table of cross-reference roles in
sphinx/domains/python.py (look for PyXRefRole), which inherits from
sphinx.roles.XRefRole, which has some notes on how to subclass and
change rendering (see 'result_nodes' method)

so..... it might even be possible to give async functions/methods their
own color :-)


================================================
FILE: docs/source/_static/.gitkeep
================================================


================================================
FILE: docs/source/_static/styles.css
================================================
/* Make .. deprecation:: blocks visible
 * (by default they're entirely unstyled)
 */
.deprecated {
    background-color: #ffe13b;
}

/* Make typevar/paramspec names distinguishable from classes. */
.typevarref {
    text-decoration: dashed underline;
}

/* Add a snakey triskelion ornament to <hr>
 * https://stackoverflow.com/questions/8862344/css-hr-with-ornament/18541258#18541258
 * but only do it to <hr>s in the content box, b/c the RTD popup control panel
 * thingummy also has an <hr> in it, and putting the ornament on that looks
 * *really weird*. (In particular, the background color is wrong.)
 */
.rst-content hr {
    overflow: visible;
}

.rst-content hr:after {
    /* This .svg gets displayed on top of the middle of the hrule. It has a box
     * behind the logo that's colored to match the RTD theme body background
     * color (#fcfcfc), which hides the middle part of the hrule to make it
     * look like there's a gap in it. The size of the box determines the size
     * of the gap.
     */
    background: url('ornament.svg') no-repeat top center;
    background-size: contain;
    content: "";
    display: block;
    height: 30px;
    position: relative;
    top: -15px;
}

/* Hacks to make the upper-left logo area look nicer */

.wy-side-nav-search > a {
    color: #306998 !important;
}

/* vertically center version text */
.wy-side-nav-search > a {
    display: flex;
    align-items: center;
    margin: auto;
    width: max-content;
}

.wy-side-nav-search > a img.logo {
    margin-left: 0;
    margin-right: 5px;
}

/* Get rid of the weird super dark "Contents" label that wastes vertical space
 */
.wy-menu-vertical > p.caption {
    display: none !important;
}

/* I do not like RTD's use of Roboto Slab for headlines. So force it back to
 * Lato (or whatever fallback it's using if Lato isn't available for some
 * reason). I also experimented with using Montserrat to be extra obnoxiously
 * on brand, but honestly you couldn't really tell so there wasn't much point
 * in adding page weight for that, and this is going to match the body text
 * better. (Montserrat for body text *definitely* didn't look good, alas.)
 */
h1, h2, h3, h4, h5, h6, legend, .rst-content .toctree-wrapper p.caption {
    font-family: inherit !important;
}

/* Get rid of the horrible red for literal content */
.rst-content tt.literal, .rst-content tt.literal, .rst-content code.literal {
    color: #222 !important;
}

/* Style the "Need help?" text just underneath the search box */
.trio-help-hint {
    line-height: normal;
    margin-bottom: 0;
    /* font-size: 12px; */
    font-size: 80%;  /* matches the "Search docs" box */
    padding-top: 6px;
    color: #306998;
    text-align: center;
}

a.trio-help-hint, .trio-help-hint a:link, .trio-help-hint a:visited {
    color: inherit;
    /* Like text-decoration: underline, but with a thinner line */
    text-decoration: none;
    border-bottom: 1px solid;
}


================================================
FILE: docs/source/_templates/.gitkeep
================================================


================================================
FILE: docs/source/_templates/genindex.html
================================================
{% extends "!genindex.html" %}

{# check sphinx/themes/basic/genindex if this snippet has become outdated #}

{% block body %}

<h1 id="index">{{ _('Index') }}</h1>

<div class="genindex-jumpbox">
 {% for key, dummy in genindexentries -%}
 <a href="#{{ key }}"><strong>{{ key }}</strong></a>
 {% if not loop.last %}| {% endif %}
 {%- endfor %}
</div>

{%- for key, entries in genindexentries %}
<h2 id="{{ key }}">{{ key }}</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
  {%- for column in entries|slice_index(2) if column %}
  <td style="width: 33%; vertical-align: top;"><ul>
    {%- for entryname, (links, subitems, _) in column %}
      {% set name = links[0][1].rsplit('#', 1)[1] if links else '' %}
      <li>{{ indexentries(name if name and '-' not in name else entryname, links) }}
      {%- if subitems %}
      <ul>
      {%- for subentryname, subentrylinks in subitems %}
        {% set sname = subentrylinks[0][1].rsplit('#', 1)[1] if subentrylinks else '' %}
        <li>{{ indexentries(sname if sname and '-' not in sname else subentryname, subentrylinks) }}</li>
      {%- endfor %}
      </ul>
      {%- endif -%}</li>
    {%- endfor %}
  </ul></td>
  {%- endfor %}
</tr></table>
{% endfor %}

{% endblock %}


================================================
FILE: docs/source/_templates/layout.html
================================================
{#
https://stackoverflow.com/questions/25243482/how-to-add-sphinx-generated-index-to-the-sidebar-when-using-read-the-docs-theme
#}
{% extends "!layout.html" %}

{% block sidebartitle %}

{# the logo helper function was removed in Sphinx 6 and deprecated since Sphinx 4 #}
{# the master_doc variable was renamed to root_doc in Sphinx 4 (master_doc still exists in later Sphinx versions) #}
{# check sphinx_rtd_theme/layout.html:sidebartitle if this snippet has become outdated #}

<a class="logo" href="{{ pathto(root_doc) }}">
  <img class="logo" src="{{ logo_url }}" />
  {%- set nav_version = version %}
  {% if current_version %}
    {%- set nav_version = current_version %}
  {% endif %}
  {# don't show the version on RTD if it's the default #}
  {% if nav_version != 'latest' %}
    <div class="trio-version">{{ nav_version }}</div>
  {% endif %}
</a>

{% include "searchbox.html" %}

<p class="trio-help-hint">Need help? <a
href="https://gitter.im/python-trio/general">Live chat</a>, <a
href="https://trio.discourse.group">forum</a>, <a
href="https://stackoverflow.com/questions/ask?tags=python+python-trio">StackOverflow</a>.</p>
{% endblock %}


================================================
FILE: docs/source/awesome-trio-libraries.rst
================================================
Awesome Trio Libraries
======================

.. List of Trio Libraries

   A list of libraries that support Trio, similar to the awesome-python
   list here: https://github.com/vinta/awesome-python/


.. currentmodule:: trio

You have completed the tutorial, and are enthusiastic about building
great new applications and libraries with async functionality.
However, to get much useful work done you will want to use some of
the great libraries that support Trio-flavoured concurrency. This list
is not complete, but gives a starting point. Another great way to find
Trio-compatible libraries is to search on PyPI for the ``Framework :: Trio``
tag -> `PyPI Search <https://pypi.org/search/?c=Framework+%3A%3A+Trio>`__


Getting Started
---------------
* `cookiecutter-trio <https://github.com/python-trio/cookiecutter-trio>`__ - This is a cookiecutter template for Python projects that use Trio. It makes it easy to start a new project, by providing a bunch of preconfigured boilerplate.
* `pytest-trio <https://github.com/python-trio/pytest-trio>`__ - Pytest plugin to test async-enabled Trio functions.
* `sphinxcontrib-trio <https://github.com/python-trio/sphinxcontrib-trio>`__ - Make Sphinx better at documenting Python functions and methods. In particular, it makes it easy to document async functions.


Web and HTML
------------
* `httpx <https://www.python-httpx.org/>`__ - HTTPX is a fully featured HTTP client for Python 3, which provides sync and async APIs, and support for both HTTP/1.1 and HTTP/2.
* `trio-websocket <https://github.com/HyperionGray/trio-websocket>`__ - A WebSocket client and server implementation striving for safety, correctness, and ergonomics.
* `quart-trio <https://github.com/pgjones/quart-trio>`__ - Like Flask, but for Trio. A simple and powerful framework for building async web applications and REST APIs. Tip: this is an ASGI-based framework, so you'll also need an HTTP server with ASGI support.
* `hypercorn <https://github.com/pgjones/hypercorn>`__ - An HTTP server for hosting your ASGI apps. Supports HTTP/1.1, HTTP/2, HTTP/3, and Websockets. Can be run as a standalone server, or embedded in a larger Trio app. Use it with ``quart-trio``, or any other Trio-compatible ASGI framework.
* `DeFramed <https://github.com/smurfix/deframed>`__ - DeFramed is a Web non-framework that supports a 99%-server-centric approach to Web coding, including support for the `Remi <https://github.com/dddomodossola/remi>`__ GUI library.
* `pura <https://github.com/groove-x/pura>`__ - A simple web framework for embedding realtime graphical visualization into Trio apps, enabling inspection and manipulation of program state during development.
* `pyscalpel <https://scalpel.readthedocs.io/en/latest/>`__ - A fast and powerful webscraping library.
* `muffin <https://github.com/klen/muffin>`_ - Muffin is a fast, simple ASGI web-framework
* `asgi-tools <https://github.com/klen/asgi-tools>`_ - Tools to quickly build lightest ASGI apps (also contains a test client with lifespan, websocket support)
* `starlette <https://github.com/encode/starlette>`_ - The little ASGI framework that shines.


Database
--------

* `triopg <https://github.com/python-trio/triopg>`__ - PostgreSQL client for Trio based on asyncpg.
* `trio-mysql <https://github.com/python-trio/trio-mysql>`__ - Pure Python MySQL Client.
* `sqlalchemy_aio <https://github.com/RazerM/sqlalchemy_aio>`__ - Add asyncio and Trio support to SQLAlchemy core, derived from alchimia.
* `redio <https://github.com/Tronic/redio>`__ - Redis client, pure Python and Trio.
* `trio_redis <https://github.com/omnidots/trio_redis>`__ - A Redis client for Trio. Depends on hiredis-py.
* `asyncakumuli <https://github.com/M-o-a-T/asyncakumuli>`__ - Client for the `Akumuli <https://akumuli.org/>`__ time series database.
* `aio-databases <https://github.com/klen/aio-databases>`_ - Async Support for various databases (triopg, trio-mysql)
* `peewee-aio <https://github.com/klen/peewee-aio>`_ - Peewee Async ORM with trio support (triopg, trio-mysql).
* `coredis <https://github.com/alisaifee/coredis>`_ - Fast, async, fully-typed Redis client with support for cluster and sentinel


IOT
---
* `DistMQTT <https://github.com/M-o-a-T/distmqtt>`__ - DistMQTT is an open source MQTT client and broker implementation. It is a fork of hbmqtt with support for anyio and DistKV.
* `asyncgpio <https://github.com/python-trio/trio-gpio>`__ - Allows easy access to the GPIO pins on your Raspberry Pi or similar embedded computer.
* `asyncowfs <https://github.com/M-o-a-T/asyncowfs>`__ - High-level, object-oriented access to 1wire sensors and actors.
* `DistKV <https://github.com/M-o-a-T/distkv>`__ - a persistent, distributed, master-less key/value storage with async notification and some IoT-related plug-ins.


Building Command Line Apps
--------------------------
* `trio-click <https://github.com/python-trio/trio-click>`__ - Python composable command line utility, trio-compatible version.
* `urwid <https://github.com/urwid/urwid>`__ - Urwid is a console user interface library for Python.


Building GUI Apps
-----------------
* `QTrio <https://qtrio.readthedocs.io/en/stable/>`__ - Integration between Trio and either the PyQt or PySide Qt wrapper libraries.  Uses Trio's :ref:`guest mode <guest-mode>`.


Multi-Core/Multiprocessing
--------------------------
* `tractor <https://github.com/goodboy/tractor>`__ - An experimental, trionic (aka structured concurrent) "actor model" for distributed multi-core Python.
* `Trio run_in_process <https://github.com/ethereum/trio-run-in-process>`__ - Trio based API for running code in a separate process.
* `trio-parallel <https://trio-parallel.readthedocs.io/>`__ - CPU parallelism for Trio


Stream Processing
-----------------
* `Slurry <https://github.com/andersea/slurry>`__ - Slurry is a microframework for building reactive, data processing applications with Trio.


Distributed Task Queue
----------------------
* `streaQ <https://github.com/tastyware/streaq>`_ - Fast, async, fully-typed distributed task queue via Redis streams


RPC
---
* `purepc <https://github.com/python-trio/purerpc>`__ - Native, async Python gRPC client and server implementation using anyio.


Testing
-------
* `pytest-trio <https://github.com/python-trio/pytest-trio>`__ - Pytest plugin for trio.
* `hypothesis-trio <https://github.com/python-trio/hypothesis-trio>`__ - Hypothesis supports Trio out of the box for
  ``@given(...)`` tests; this extension provides Trio-compatible stateful testing.
* `trustme <https://github.com/python-trio/trustme>`__ - #1 quality TLS certs while you wait, for the discerning tester.
* `pytest-aio <https://github.com/klen/pytest-aio>`_ - Pytest plugin with support for trio, curio, asyncio
* `logot <https://github.com/etianen/logot>`_ - Test whether your async code is logging correctly.


Tools and Utilities
-------------------
* `trio-util <https://github.com/groove-x/trio-util>`__ - An assortment of utilities for the Trio async/await framework.
* `flake8-async <https://github.com/python-trio/flake8-async>`__ - Highly opinionated linter for various sorts of problems in Trio, AnyIO and/or asyncio. Can run as a flake8 plugin, or standalone with support for autofixing some errors.
* `tricycle <https://github.com/oremanj/tricycle>`__ - This is a library of interesting-but-maybe-not-yet-fully-proven extensions to Trio.
* `tenacity <https://github.com/jd/tenacity>`__ - Retrying library for Python with async/await support.
* `perf-timer <https://github.com/belm0/perf-timer>`__ - A code timer with Trio async support (see ``TrioPerfTimer``).  Collects execution time of a block of code excluding time when the coroutine isn't scheduled, such as during blocking I/O and sleep.  Also offers ``trio_perf_counter()`` for low-level timing.
* `aiometer <https://github.com/florimondmanca/aiometer>`__ - Execute lots of tasks concurrently while controlling concurrency limits
* `triotp <https://linkdd.github.io/triotp>`__ - OTP framework for Python Trio
* `aioresult <https://github.com/arthur-tacca/aioresult>`__ - Get the return value of a background async function in Trio or anyio, along with a simple Future class and wait utilities
* `aiologic <https://github.com/x42005e1f/aiologic>`__ - Thread-safe synchronization and communication primitives: locks, capacity limiters, queues, etc.
* `culsans <https://github.com/x42005e1f/culsans>`__ - Janus-like sync-async queue with Trio support. Unlike aiologic queues, provides API compatible interfaces.


Trio/Asyncio Interoperability
-----------------------------
* `anyio <https://github.com/agronholm/anyio>`__ - AnyIO is a asynchronous compatibility API that allows applications and libraries written against it to run unmodified on asyncio or trio.
* `sniffio <https://github.com/python-trio/sniffio>`__ - This is a tiny package whose only purpose is to let you detect which async library your code is running under.
* `trio-asyncio <https://github.com/python-trio/trio-asyncio>`__ - Trio-Asyncio lets you use many asyncio libraries from your Trio app.


================================================
FILE: docs/source/code-of-conduct.rst
================================================
.. _code-of-conduct:

Code of Conduct
===============

This code of conduct applies to the Trio project, and all associated
projects in the `python-trio <https://github.com/python-trio>`__
organization.


.. _coc-when-something-happens:

When Something Happens
----------------------

If you see a Code of Conduct violation, follow these steps:

1. Let the person know that what they did is not appropriate and ask
   them to stop and/or edit their message(s) or commits.
2. That person should immediately stop the behavior and correct the
   issue.
3. If this doesn't happen, or if you're uncomfortable speaking up,
   :ref:`contact the maintainers <coc-contacting-maintainers>`.
4. As soon as possible, a maintainer will look into the issue, and take
   :ref:`further action (see below) <coc-further-enforcement>`, starting with
   a warning, then temporary block, then long-term repo or organization
   ban.

When reporting, please include any relevant details, links, screenshots,
context, or other information that may be used to better understand and
resolve the situation.

**The maintainer team will prioritize the well-being and comfort of the
recipients of the violation over the comfort of the violator.** See
:ref:`some examples below <coc-enforcement-examples>`.

Our Pledge
----------

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers of this project pledge to making
participation in our community a harassment-free experience for
everyone, regardless of age, body size, disability, ethnicity, gender
identity and expression, level of experience, technical preferences,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

Our Standards
-------------

Examples of behavior that contributes to creating a positive environment
include:

-  Using welcoming and inclusive language.
-  Being respectful of differing viewpoints and experiences.
-  Gracefully accepting constructive feedback.
-  Focusing on what is best for the community.
-  Showing empathy and kindness towards other community members.
-  Encouraging and raising up your peers in the project so you can all
   bask in hacks and glory.

Examples of unacceptable behavior by participants include:

-  The use of sexualized language or imagery and unwelcome sexual
   attention or advances, including when simulated online. The only
   exception to sexual topics is channels/spaces specifically for topics
   of sexual identity.
-  Casual mention of slavery or indentured servitude and/or false
   comparisons of one's occupation or situation to slavery. Please
   consider using or asking about alternate terminology when referring
   to such metaphors in technology.
-  Making light of/making mocking comments about trigger warnings and
   content warnings.
-  Trolling, insulting/derogatory comments, and personal or political
   attacks.
-  Public or private harassment, deliberate intimidation, or threats.
-  Publishing others' private information, such as a physical or
   electronic address, without explicit permission. This includes any
   sort of "outing" of any aspect of someone's identity without their
   consent.
-  Publishing screenshots or quotes of private interactions in the
   context of this project without all quoted users' *explicit* consent.
-  Publishing of private communication that doesn't have to do with
   reporting harassment.
-  Any of the above even when `presented as "ironic" or
   "joking" <https://en.wikipedia.org/wiki/Hipster_racism>`__.
-  Any attempt to present "reverse-ism" versions of the above as
   violations. Examples of reverse-isms are "reverse racism", "reverse
   sexism", "heterophobia", and "cisphobia".
-  Unsolicited explanations under the assumption that someone doesn't
   already know it. Ask before you teach! Don't assume what people's
   knowledge gaps are.
-  `Feigning or exaggerating
   surprise <https://www.recurse.com/manual#no-feigned-surprise>`__ when
   someone admits to not knowing something.
-  "`Well-actuallies <https://www.recurse.com/manual#no-well-actuallys>`__"
-  Other conduct which could reasonably be considered inappropriate in a
   professional or community setting.

Scope
-----

This Code of Conduct applies both within spaces involving this project
and in other spaces involving community members. This includes the
repository, its Pull Requests and Issue tracker, its Twitter community,
private email communications in the context of the project, and any
events where members of the project are participating, as well as
adjacent communities and venues affecting the project's members.

Depending on the violation, the maintainers may decide that violations
of this code of conduct that have happened outside of the scope of the
community may deem an individual unwelcome, and take appropriate action
to maintain the comfort and safety of its members.

.. _coc-other-community-standards:

Other Community Standards
~~~~~~~~~~~~~~~~~~~~~~~~~

As a project on GitHub, this project is additionally covered by the
`GitHub Community
Guidelines <https://help.github.com/articles/github-community-guidelines/>`__.

Enforcement of those guidelines after violations overlapping with the
above are the responsibility of the entities, and enforcement may happen
in any or all of the services/communities.

Maintainer Enforcement Process
------------------------------

Once the maintainers get involved, they will follow a documented series
of steps and do their best to preserve the well-being of project
members. This section covers actual concrete steps.


.. _coc-contacting-maintainers:

Contacting Maintainers
~~~~~~~~~~~~~~~~~~~~~~

As a small project, we don't have a Code of Conduct enforcement team.
Hopefully that will be addressed as we grow, but for now, any issues
should be addressed to `Nathaniel J. Smith
<https://github.com/njsmith>`__, via `email <mailto:njs@pobox.com>`__
or any other medium that you feel comfortable with. Using words like
"Trio code of conduct" in your subject will help make sure your
message is noticed quickly.


.. _coc-further-enforcement:

Further Enforcement
~~~~~~~~~~~~~~~~~~~

If you've already followed the :ref:`initial enforcement steps
<coc-when-something-happens>`, these are the steps maintainers will
take for further enforcement, as needed:

1. Repeat the request to stop.
2. If the person doubles down, they will have offending messages removed
   or edited by a maintainers given an official warning. The PR or Issue
   may be locked.
3. If the behavior continues or is repeated later, the person will be
   blocked from participating for 24 hours.
4. If the behavior continues or is repeated after the temporary block, a
   long-term (6-12mo) ban will be used.
5. If after this the behavior still continues, a permanent ban may be
   enforced.

On top of this, maintainers may remove any offending messages, images,
contributions, etc, as they deem necessary.

Maintainers reserve full rights to skip any of these steps, at their
discretion, if the violation is considered to be a serious and/or
immediate threat to the health and well-being of members of the
community. These include any threats, serious physical or verbal
attacks, and other such behavior that would be completely unacceptable
in any social setting that puts our members at risk.

Members expelled from events or venues with any sort of paid attendance
will not be refunded.

Who Watches the Watchers?
~~~~~~~~~~~~~~~~~~~~~~~~~

Maintainers and other leaders who do not follow or enforce the Code of
Conduct in good faith may face temporary or permanent repercussions as
determined by other members of the project's leadership. These may
include anything from removal from the maintainer team to a permanent
ban from the community.

Additionally, as a project hosted on GitHub, :ref:`their Code of
Conduct may be applied against maintainers of this project
<coc-other-community-standards>`, externally of this project's
procedures.


.. _coc-enforcement-examples:

Enforcement Examples
--------------------

The Best Case
~~~~~~~~~~~~~

The vast majority of situations work out like this. This interaction is
common, and generally positive.

    Alex: "Yeah I used X and it was really crazy!"

    Patt (not a maintainer): "Hey, could you not use that word? What
    about 'ridiculous' instead?"

    Alex: "oh sorry, sure." -> edits old comment to say "it was really
    confusing!"

The Maintainer Case
~~~~~~~~~~~~~~~~~~~

Sometimes, though, you need to get maintainers involved. Maintainers
will do their best to resolve conflicts, but people who were harmed by
something **will take priority**.

    Patt: "Honestly, sometimes I just really hate using $library and
    anyone who uses it probably sucks at their job."

    Alex: "Whoa there, could you dial it back a bit? There's a CoC thing
    about attacking folks' tech use like that."

    Patt: "I'm not attacking anyone, what's your problem?"

    Alex: "@maintainers hey uh. Can someone look at this issue? Patt is
    getting a bit aggro. I tried to nudge them about it, but nope."

    KeeperOfCommitBits: (on issue) "Hey Patt, maintainer here. Could you
    tone it down? This sort of attack is really not okay in this space."

    Patt: "Leave me alone I haven't said anything bad wtf is wrong with
    you."

    KeeperOfCommitBits: (deletes user's comment), "@patt I mean it.
    Please refer to the CoC over at (URL to this CoC) if you have
    questions, but you can consider this an actual warning. I'd
    appreciate it if you reworded your messages in this thread, since
    they made folks there uncomfortable. Let's try and be kind, yeah?"

    Patt: "@keeperofbits Okay sorry. I'm just frustrated and I'm kinda
    burnt out and I guess I got carried away. I'll DM Alex a note
    apologizing and edit my messages. Sorry for the trouble."

    KeeperOfCommitBits: "@patt Thanks for that. I hear you on the
    stress. Burnout sucks :/. Have a good one!"

The Nope Case
~~~~~~~~~~~~~

    PepeTheFrog🐸: "Hi, I am a literal actual nazi and I think white
    supremacists are quite fashionable."

    Patt: "NOOOOPE. OH NOPE NOPE."

    Alex: "JFC NO. NOPE. @keeperofbits NOPE NOPE LOOK HERE"

    KeeperOfCommitBits: "👀 Nope. NOPE NOPE NOPE. 🔥"

    PepeTheFrog🐸 has been banned from all organization or user
    repositories belonging to KeeperOfCommitBits.

Attribution
-----------

This Code of Conduct was generated using `WeAllJS Code of Conduct
Generator <https://npm.im/weallbehave>`__, which is based on the
`WeAllJS Code of Conduct <https://wealljs.org/code-of-conduct>`__, which
is itself based on `Contributor
Covenant <http://contributor-covenant.org>`__, version 1.4, available at
http://contributor-covenant.org/version/1/4, and the LGBTQ in Technology
Slack `Code of Conduct <http://lgbtq.technology/coc.html>`__.


================================================
FILE: docs/source/conf.py
================================================
#!/usr/bin/env python3
#
# Trio documentation build configuration file, created by
# sphinx-quickstart on Sat Jan 21 19:11:14 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
from __future__ import annotations

import collections.abc
import glob
import os
import sys
from pathlib import Path
from typing import TYPE_CHECKING, cast

if sys.version_info >= (3, 11):
    from sphinx.util.inventory import _InventoryItem

from sphinx.util.logging import getLogger

if TYPE_CHECKING:
    from sphinx.application import Sphinx
    from sphinx.util.typing import Inventory

# For our local_customization module
sys.path.insert(0, os.path.abspath("."))

# Enable reloading with `typing.TYPE_CHECKING` being True
os.environ["SPHINX_AUTODOC_RELOAD_MODULES"] = "1"

# Handle writing newsfragments into the history file.
# We want to keep files unchanged when testing locally.
# So immediately revert the contents after running towncrier,
# then substitute when Sphinx wants to read it in.
history_file = Path("history.rst")

history_new: str | None
if glob.glob("../../newsfragments/*.*.rst"):
    print("-- Found newsfragments; running towncrier --", flush=True)
    history_orig = history_file.read_bytes()
    import subprocess

    # In case changes were staged, preserve indexed version.
    # This grabs the hash of the current staged version.
    history_staged = subprocess.run(
        ["git", "rev-parse", "--verify", ":docs/source/history.rst"],
        check=True,
        cwd="../..",
        stdout=subprocess.PIPE,
        encoding="ascii",
    ).stdout.strip()
    try:
        subprocess.run(
            ["towncrier", "--keep", "--date", "not released yet"],
            cwd="../..",
            check=True,
        )
        history_new = history_file.read_text("utf8")
    finally:
        # Make sure this reverts even if a failure occurred.
        # Restore whatever was staged.
        print(f"Restoring history.rst = {history_staged}")
        subprocess.run(
            [
                "git",
                "update-index",
                "--cacheinfo",
                f"100644,{history_staged},docs/source/history.rst",
            ],
            cwd="../..",
            check=False,
        )
        # And restore the working copy.
        history_file.write_bytes(history_orig)
    del history_orig  # We don't need this any more.
else:
    # Leave it as is.
    history_new = None


def on_read_source(app: Sphinx, docname: str, content: list[str]) -> None:
    """Substitute the modified history file."""
    if docname == "history" and history_new is not None:
        # This is a 1-item list with the file contents.
        content[0] = history_new


# Sphinx is very finicky, and somewhat buggy, so we have several different
# methods to help it resolve links.
# 1. The ones that are not possible to fix are added to `nitpick_ignore`
# 2. some can be resolved with a simple alias in `autodoc_type_aliases`,
#    even if that is primarily meant for TypeAliases
# 3. autodoc_process_signature is hooked up to an event, and we use it for
#    whole-sale replacing types in signatures where internal details are not
#    relevant or hard to read.
# 4. add_intersphinx manually modifies the intersphinx mappings after
#    objects.inv has been parsed, to resolve bugs and version differences
#    that causes some objects to be looked up incorrectly.
# 5. docs/source/typevars.py handles redirecting `typing_extensions` objects to `typing`, and linking `TypeVar`s to `typing.TypeVar` instead of sphinx wanting to link them to their individual definitions.
# It's possible there's better methods for resolving some of the above
# problems, but this works for now:tm:

# Warn about all references to unknown targets
nitpicky = True
# Except for these ones, which we expect to point to unknown targets:
nitpick_ignore = [
    ("py:class", "CapacityLimiter-like object"),
    ("py:class", "bytes-like"),
    # Was removed but still shows up in changelog
    ("py:class", "trio.lowlevel.RunLocal"),
    # trio.abc is documented at random places scattered throughout the docs
    ("py:mod", "trio.abc"),
    ("py:exc", "Anything else"),
    ("py:class", "async function"),
    ("py:class", "sync function"),
    # these do not have documentation on python.org
    # nor entries in objects.inv
    ("py:class", "socket.AddressFamily"),
    ("py:class", "socket.SocketKind"),
]
autodoc_inherit_docstrings = False
default_role = "obj"


# A dictionary for users defined type aliases that maps a type name to the full-qualified object name. It is used to keep type aliases not evaluated in the document.
# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#confval-autodoc_type_aliases
# but it can also be used to help resolve various linking problems
autodoc_type_aliases = {
    # SSLListener.accept's return type is seen as trio._ssl.SSLStream
    "SSLStream": "trio.SSLStream",
}


# https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#event-autodoc-process-signature
def autodoc_process_signature(
    app: Sphinx,
    what: str,
    name: str,
    obj: object,
    options: object,
    signature: str,
    return_annotation: str,
) -> tuple[str, str]:
    """Modify found signatures to fix various issues."""
    if signature is not None:
        signature = signature.replace("~_contextvars.Context", "~contextvars.Context")
        if name == "trio.lowlevel.RunVar":  # Typevar is not useful here.
            signature = signature.replace(": ~trio._core._local.T", "")
        if "_NoValue" in signature:
            # Strip the type from the union, make it look like = ...
            signature = signature.replace(" | type[trio._core._local._NoValue]", "")
            signature = signature.replace("<class 'trio._core._local._NoValue'>", "...")
        if "DTLS" in name:
            signature = signature.replace("SSL.Context", "OpenSSL.SSL.Context")
        # Don't specify PathLike[str] | PathLike[bytes], this is just for humans.
        signature = signature.replace("StrOrBytesPath", "str | bytes | os.PathLike")

    return signature, return_annotation


# currently undocumented things
logger = getLogger("trio")
UNDOCUMENTED = {
    "trio.MemorySendChannel",
    "trio.MemoryReceiveChannel",
    "trio.MemoryChannelStatistics",
    "trio.SocketStream.aclose",
    "trio.SocketStream.receive_some",
    "trio.SocketStream.send_all",
    "trio.SocketStream.send_eof",
    "trio.SocketStream.wait_send_all_might_not_block",
    "trio._subprocess.HasFileno.fileno",
    "trio.lowlevel.ParkingLot.broken_by",
}


def autodoc_process_docstring(
    app: Sphinx,
    what: str,
    name: str,
    obj: object,
    options: object,
    lines: list[str],
) -> None:
    if not lines:
        # TODO: document these and remove them from here
        if name in UNDOCUMENTED:
            return

        logger.warning(f"{name} has no docstring")
    else:
        if name in UNDOCUMENTED:
            logger.warning(
                f"outdated list of undocumented things in docs/source/conf.py: {name!r} has a docstring"
            )


def setup(app: Sphinx) -> None:
    # Add our custom styling to make our documentation better!
    app.add_css_file("styles.css")
    app.connect("autodoc-process-signature", autodoc_process_signature)
    app.connect("autodoc-process-docstring", autodoc_process_docstring)

    # After Intersphinx runs, add additional mappings.
    app.connect("builder-inited", add_intersphinx, priority=1000)
    app.connect("source-read", on_read_source)


html_context = {"current_version": os.environ.get("READTHEDOCS_VERSION_NAME")}

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    "sphinx.ext.autodoc",
    "sphinx.ext.intersphinx",
    "sphinx.ext.coverage",
    "sphinx.ext.napoleon",
    "sphinxcontrib_trio",
    "sphinxcontrib.jquery",
    "sphinx_codeautolink",
    "local_customization",
    "typevars",
]

intersphinx_mapping = {
    "python": ("https://docs.python.org/3", None),
    "outcome": ("https://outcome.readthedocs.io/en/latest/", None),
    "pyopenssl": ("https://www.pyopenssl.org/en/stable/", None),
    "sniffio": ("https://sniffio.readthedocs.io/en/latest/", None),
    "trio-util": ("https://trio-util.readthedocs.io/en/latest/", None),
    "flake8-async": ("https://flake8-async.readthedocs.io/en/latest/", None),
}

# See https://sphinx-codeautolink.readthedocs.io/en/latest/reference.html#configuration
codeautolink_autodoc_inject = False
codeautolink_global_preface = """
import trio
from trio import *
"""


def add_intersphinx(app: Sphinx) -> None:
    """Add some specific intersphinx mappings.

    Hooked up to builder-inited. app.builder.env.interpshinx_inventory is not an official API, so this may break on new sphinx versions.
    """

    def add_mapping(
        reftype: str,
        library: str,
        obj: str,
        version: str = "3.12",
        target: str | None = None,
    ) -> None:
        """helper function"""
        url_version = "3" if version == "3.12" else version
        if target is None:
            target = f"{library}.{obj}"

        # sphinx doing fancy caching stuff makes this attribute invisible
        # to type checkers
        inventory = app.builder.env.intersphinx_inventory  # type: ignore[attr-defined]
        assert isinstance(inventory, dict)
        inventory = cast("Inventory", inventory)

        if sys.version_info >= (3, 11):
            inventory[f"py:{reftype}"][f"{target}"] = _InventoryItem(
                project_name="Python",
                project_version=version,
                uri=f"https://docs.python.org/{url_version}/library/{library}.html/{obj}",
                display_name="-",
            )
        else:
            inventory[f"py:{reftype}"][f"{target}"] = (
                "Python",
                version,
                f"https://docs.python.org/{url_version}/library/{library}.html/{obj}",
                "-",
            )

    # This has been removed in Py3.12, so add a link to the 3.11 version with deprecation warnings.
    add_mapping("method", "pathlib", "Path.link_to", "3.11")

    # defined in py:data in objects.inv, but sphinx looks for a py:class
    # see https://github.com/sphinx-doc/sphinx/issues/10974
    # to dump the objects.inv for the stdlib, you can run
    # python -m sphinx.ext.intersphinx http://docs.python.org/3/objects.inv
    add_mapping("class", "math", "inf")
    add_mapping("class", "types", "FrameType")

    # new in py3.12, and need target because sphinx is unable to look up
    # the module of the object if compiling on <3.12
    if not hasattr(collections.abc, "Buffer"):
        add_mapping("class", "collections.abc", "Buffer", target="Buffer")


autodoc_member_order = "bysource"

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"

# The master toctree document.
master_doc = "index"

# General information about the project.
project = "Trio"
copyright = "2017, Nathaniel J. Smith"  # noqa: A001 # Name shadows builtin
author = "Nathaniel J. Smith"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
import importlib.metadata

version = importlib.metadata.version("trio")
# The full version, including alpha/beta/rc tags.
release = version

html_favicon = "_static/favicon-32.png"
html_logo = "../../logo/wordmark-transparent.svg"
# & down below in html_theme_options we set logo_only=True

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns: list[str] = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "default"

highlight_language = "python3"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

# This avoids a warning by the epub builder that it can't figure out
# the MIME type for our favicon.
suppress_warnings = ["epub.unknown_project_files"]


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
# html_theme = 'alabaster'

# We have to set this ourselves, not only because it's useful for local
# testing, but also because if we don't then RTD will throw away our
# html_theme_options.
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
    # default is 2
    # show deeper nesting in the RTD theme's sidebar TOC
    # https://stackoverflow.com/questions/27669376/
    # I'm not 100% sure this actually does anything with our current
    # versions/settings...
    "navigation_depth": 4,
    "logo_only": True,
    "prev_next_buttons_location": "both",
    "style_nav_header_background": "#d2e7fa",
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = "Triodoc"


# -- Options for LaTeX output ---------------------------------------------

latex_elements: dict[str, object] = {
    # The paper size ('letterpaper' or 'a4paper').
    #
    # 'papersize': 'letterpaper',
    # The font size ('10pt', '11pt' or '12pt').
    #
    # 'pointsize': '10pt',
    # Additional stuff for the LaTeX preamble.
    #
    # 'preamble': '',
    # Latex figure (float) alignment
    #
    # 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
    (master_doc, "Trio.tex", "Trio Documentation", "Nathaniel J. Smith", "manual"),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "trio", "Trio Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
    (
        master_doc,
        "Trio",
        "Trio Documentation",
        author,
        "Trio",
        "One line description of project.",
        "Miscellaneous",
    ),
]


================================================
FILE: docs/source/contributing.rst
================================================
.. _contributing:

Contributing to Trio and related projects
=========================================

So you're interested in contributing to Trio or `one of our associated
projects <https://github.com/python-trio>`__? That's awesome! Trio is
an open-source project maintained by an informal group of
volunteers. Our goal is to make async I/O in Python more fun, easy,
and reliable, and we can't do it without help from people like you. We
welcome contributions from anyone willing to work in good faith with
other contributors and the community (see also our
:ref:`code-of-conduct`).

There are many ways to contribute, no contribution is too small, and
all contributions are valued.  For example, you could:

- Hang out in our `chatroom <https://gitter.im/python-trio/general>`__
  and help people with questions.
- Sign up for our `forum <https://trio.discourse.group>`__, set up
  your notifications so you notice interesting conversations, and join
  in.
- Answer questions on StackOverflow (`recent questions
  <https://stackexchange.com/filters/289914/trio-project-tags-on-stackoverflow-filter>`__).
- Use Trio in a project, and give us feedback on what worked and what
  didn't.
- Write a blog post about your experiences with Trio, good or bad.
- Release open-source programs and libraries that use Trio.
- Improve documentation.
- Comment on issues.
- Add tests.
- Fix bugs.
- Add features.

We want contributing to be enjoyable and mutually beneficial; this
document tries to give you some tips to help that happen, and applies
to all of the projects under the `python-trio organization on Github
<https://github.com/python-trio>`__. If you have thoughts on how it
can be improved then please let us know.


Getting started
---------------

If you're new to open source in general, you might find it useful to
check out `opensource.guide's How to Contribute to Open Source
tutorial <https://opensource.guide/how-to-contribute/>`__, or if
video's more your thing, `egghead.io has a short free video course
<https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github>`__.

Trio and associated projects are developed on GitHub, under the
`python-trio <https://github.com/python-trio>`__ organization. Code
and documentation changes are made through pull requests (see
:ref:`preparing-pull-requests` below).

We also have an unusual policy for managing commit rights: anyone
whose pull request is merged is automatically invited to join the
GitHub organization, and gets commit rights to all of our
repositories. See :ref:`joining-the-team` below for more details.

If you're looking for a good place to start, then check out our issues
labeled `good first issue
<https://github.com/search?utf8=%E2%9C%93&q=user%3Apython-trio+label%3A%22good+first+issue%22+state%3Aopen&type=Issues&ref=advsearch&l=&l=>`__,
or feel free to ask `on the forum <https://trio.discourse.group>`__ or
`in chat <https://gitter.im/python-trio/general>`__.


Providing support
-----------------

When helping others use Trio, please remember that you are
representing our community, and we want this to be a friendly and
welcoming place.

Concurrency is *really confusing* when you're first learning. When
talking to beginners, remember that you were a beginner once too, and
the whole goal here is to make a top-tier concurrency library that's
accessible to everyone and a joy to use. If people are showing up with
beginner questions, *that means we're succeeding*. How we respond to
questions is part of that developer experience, just as much as our
API, documentation, or testing tools. And as a bonus, helping
beginners is often the best way to discover ideas for improvements. If
you start getting burned out and cranky, we've all been there, and
it's OK to take a break until you feel better. But it's not OK to take
that out on random users.

Please remember that the authors and users of competing projects are
smart, thoughtful people doing their best to balance complicated and
conflicting requirements, just like us. Of course it's totally fine to
make specific technical critiques ("In project X, this is handled by
doing Y, Trio does Z instead, which I prefer because...") or talk
about your personal experience ("I tried using X but I got super
frustrated and confused"), but refrain from generic statements like "X
sucks" or "I can't believe anyone uses X".

Please try not to make assumptions about people's gender, and in
particular remember that we're not all dudes. If you don't have a
specific reason to assume otherwise, then `singular they
<https://en.wikipedia.org/wiki/Third-person_pronoun#Singular_they>`__
makes a fine pronoun, and there are plenty of gender-neutral
collective terms: "Hey folks", "Hi all", ...

We also like the Recurse Center's `social rules
<https://www.recurse.com/manual#sub-sec-social-rules>`__:

* no feigning surprise (also available in a `sweet comic version
  <https://jvns.ca/blog/2017/04/27/no-feigning-surprise/>`__)
* no well-actually's
* no subtle -isms (`more details <https://www.recurse.com/blog/38-subtle-isms-at-hacker-school>`__)


.. _preparing-pull-requests:

Preparing pull requests
-----------------------

If you want to submit a documentation or code change to one of the
Trio projects, then that's done by preparing a Github pull request (or
"PR" for short). We'll do our best to review your PR quickly. If it's
been a week or two and you're still waiting for a response, feel free
to post a comment poking us. (This can just be a comment with the
single word "ping"; it's not rude at all.)

Here's a quick checklist for putting together a good PR, with details
in separate sections below:

* :ref:`pull-request-scope`: Does your PR address a single,
  self-contained issue?

* :ref:`pull-request-tests`: Are your tests passing? Did you add any
  necessary tests? Code changes pretty much always require test
  changes, because if it's worth fixing the code then it's worth
  adding a test to make sure it stays fixed.

* :ref:`pull-request-formatting`: If you changed Python code, then did
  you run ``black trio``? (Or for other packages, replace
  ``trio`` with the package name.)

* :ref:`pull-request-release-notes`: If your change affects
  user-visible functionality, then did you add a release note to the
  ``newsfragments/`` directory?

* :ref:`pull-request-docs`: Did you make any necessary documentation
  updates?

* License: by submitting a PR to a Trio project, you're offering your
  changes under that project's license. For most projects, that's dual
  MIT/Apache 2, except for cookiecutter-trio, which is CC0.


.. _pull-request-scope:

What to put in a PR
~~~~~~~~~~~~~~~~~~~

Each PR should, as much as possible, address just one issue and be
self-contained. If you have ten small, unrelated changes, then go
ahead and submit ten PRs – it's much easier to review ten small
changes than one big change with them all mixed together, and this way
if there's some problem with one of the changes it won't hold up all
the others.

If you're uncertain about whether a change is a good idea and want
some feedback before putting time into it, feel free to ask in an
issue or in the chat room. If you have a partial change that you want
to get feedback on, feel free to submit it as a PR. (In this case it's
traditional to start the PR title with ``[WIP]``, for "work in
progress".)

When you are submitting your PR, you can include ``Closes #123``,
``Fixes: #123`` or
`some variation <https://help.github.com/en/articles/closing-issues-using-keywords>`__
in either your commit message or the PR description, in order to
automatically close the referenced issue when the PR is merged.
This keeps us closer to the desired state where each open issue reflects some
work that still needs to be done.


Environment
~~~~~~~~~~~
We strongly suggest using a virtual environment for managing dependencies,
for example with `venv <https://docs.python.org/3/library/venv.html>`__. So to
set up your environment and install dependencies, you should run something like:

.. code-block:: shell

   cd path/to/trio/checkout/
   python -m venv .venv # create virtual env in .venv
   source .venv/bin/activate # activate it
   pip install -e . # install trio, needed for pytest plugin
   pip install -r test-requirements.txt # install test requirements

you rarely need to recreate the virtual environment, but you need to re-activate it
in future terminals. You might also need to re-install from test-requirements.txt if
the versions in it get updated.

.. _pull-request-tests:

Tests
~~~~~

We use `pytest <https://pytest.org/>`__ for testing. To run the tests
locally, you should run:

.. code-block:: shell

   source .venv/bin/activate # if not already activated
   pytest src

This doesn't try to be completely exhaustive – it only checks that
things work on your machine, and it will skip some slow tests. But it's
a good way to quickly check that things seem to be working, and we'll
automatically run the full test suite when your PR is submitted, so
you'll have a chance to see and fix any remaining issues then.

Every change should have 100% coverage for both code and tests. But,
you can use ``# pragma: no cover`` to mark lines where
lack-of-coverage isn't something that we'd want to fix (as opposed to
it being merely hard to fix). For example:

.. code-block:: python

    if ...:
        ...
    else:  # pragma: no cover
        raise AssertionError("this can't happen!")

We use Codecov to track coverage, because it makes it easy to combine
coverage from running in different configurations. Running coverage
locally can be useful

.. code-block:: shell

   coverage run -m pytest
   coverage combine
   coverage report

but don't be surprised if you get lower coverage than when looking at Codecov
reports, because there are some lines that are only executed on
Windows, or macOS, or PyPy, or CPython, or... you get the idea. After
you create a PR, Codecov will automatically report back with the
coverage, so you can check how you're really doing. (But note that the
results can be inaccurate until all the tests are passing. If the
tests failed, then fix that before worrying about coverage.)

Some rules for writing good tests:

* `Tests MUST pass deterministically
  <https://github.com/python-trio/trio/issues/200>`__. Flakey tests
  make for miserable developers. One common source of indeterminism is
  scheduler ordering; if you're having trouble with this, then
  :mod:`trio.testing` provides powerful tools to help control
  ordering, like :func:`trio.testing.wait_all_tasks_blocked`,
  :class:`trio.testing.Sequencer`, and :class:`trio.testing.MockClock`
  (usually used as a fixture: ``async def
  test_whatever(autojump_clock): ...``). And if you need more tools
  than this then we should add them.

* (Trio package only) Slow tests – anything that takes more than about
  0.25 seconds – should be marked with ``@slow``. This makes it so they
  only run if you do ``pytest trio --run-slow``. Our CI scripts do
  run slow tests, so you can be sure that the code will still be
  thoroughly tested, and this way you don't have to sit around waiting
  for a few irrelevant multi-second tests to run while you're iterating
  on a change locally.

  You can check for slow tests by passing ``--durations=10`` to
  pytest. Most tests should take 0.01 seconds or less.

* Speaking of waiting around for tests: Tests should never sleep
  unless *absolutely* necessary. However, calling :func:`trio.sleep`
  when using ``autojump_clock`` is fine, because that's not really
  sleeping, and doesn't waste developers time waiting for the test to
  run.

* We like tests to exercise real functionality. For example, if you're
  adding subprocess spawning functionality, then your tests should
  spawn at least one process! Sometimes this is tricky – for example,
  Trio's :class:`KeyboardInterrupt` tests have to jump through quite
  some hoops to generate real SIGINT signals at the right times to
  exercise different paths. But it's almost always worth it.

* For cases where real testing isn't relevant or sufficient, then we
  strongly prefer fakes or stubs over mocks. Useful articles:

  * `Test Doubles - Fakes, Mocks and Stubs
    <https://dev.to/milipski/test-doubles---fakes-mocks-and-stubs>`__

  * `Mocks aren't stubs
    <https://martinfowler.com/articles/mocksArentStubs.html>`__

  * `Write test doubles you can trust using verified fakes
    <https://codewithoutrules.com/2016/07/31/verified-fakes/>`__

  Most major features have both real tests and tests using fakes or
  stubs. For example, :class:`~trio.SSLStream` has some tests that
  use Trio to make a real socket connection to real SSL server
  implemented using blocking I/O, because it sure would be
  embarrassing if that didn't work. And then there are also a bunch of
  tests that use a fake in-memory transport stream where we have
  complete control over timing and can make sure all the subtle edge
  cases work correctly.

Writing reliable tests for obscure corner cases is often harder than
implementing a feature in the first place, but stick with it: it's
worth it! And don't be afraid to ask for help. Sometimes a fresh pair
of eyes can be helpful when trying to come up with devious tricks.


.. _pull-request-formatting:

Code formatting
~~~~~~~~~~~~~~~

Instead of wasting time arguing about code formatting, we use `black
<https://github.com/psf/black>`__ as well as other tools to automatically
format all our code to a standard style. While you're editing code you
can be as sloppy as you like about whitespace; and then before you commit,
just run:

.. code-block:: text

    pip install -U pre-commit
    pre-commit

to fix it up. (And don't worry if you forget – when you submit a pull
request then we'll automatically check and remind you.) Hopefully this
will let you focus on more important style issues like choosing good
names, writing useful comments, and making sure your docstrings are
nicely formatted. (black doesn't reformat comments or docstrings.)

If you would like, you can even have pre-commit run before you commit by
running:

.. code-block:: text

    pre-commit install

and now pre-commit will run before git commits. You can uninstall the
pre-commit hook at any time by running:

.. code-block:: text

    pre-commit uninstall


Very occasionally, you'll want to override black formatting. To do so,
you can can add ``# fmt: off`` and ``# fmt: on`` comments.

If you want to see what changes black will make, you can use:

.. code-block:: text

    black --diff trio

(``--diff`` displays a diff, versus the default mode which fixes files
in-place.)


Additionally, in some cases it is necessary to disable isort changing the
order of imports. To do so you can add ``# isort: split`` comments.
For more information, please see `isort's docs <https://pycqa.github.io/isort/docs/configuration/action_comments.html>`__.


.. _pull-request-release-notes:

Release notes
~~~~~~~~~~~~~

We use `towncrier <https://github.com/hawkowl/towncrier>`__ to manage
our `release notes <https://trio.readthedocs.io/en/latest/history.html>`__.
Basically, every pull request that has a user
visible effect should add a short file to the ``newsfragments/``
directory describing the change, with a name like ``<ISSUE
NUMBER>.<TYPE>.rst``. See `newsfragments/README.rst
<https://github.com/python-trio/trio/blob/main/newsfragments/README.rst>`__
for details. This way we can keep a good list of changes as we go,
which makes the release manager happy, which means we get more
frequent releases, which means your change gets into users' hands
faster.


.. _pull-request-commit-messages:

Commit messages
~~~~~~~~~~~~~~~

We don't enforce any particular format on commit messages. In your
commit messages, try to give the context to explain *why* a change was
made.

The target audience for release notes is users, who want to find out
about changes that might affect how they use the library, or who are
trying to figure out why something changed after they upgraded.

The target audience for commit messages is some hapless developer
(think: you in six months... or five years) who is trying to figure
out why some code looks the way it does. Including links to issues and
any other discussion that led up to the commit is *strongly*
recommended.


.. _pull-request-docs:

Documentation
~~~~~~~~~~~~~

We take pride in providing friendly and comprehensive documentation.
Documentation is stored in ``docs/source/*.rst`` and is rendered using
`Sphinx <http://www.sphinx-doc.org/>`__ with the `sphinxcontrib-trio
<https://sphinxcontrib-trio.readthedocs.io/en/latest/>`__ extension.
Documentation is hosted at `Read the Docs
<https://readthedocs.org/>`__, who take care of automatically
rebuilding it after every commit.

For docstrings, we use `the Google docstring format
<https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html#example-google-style-python-docstrings>`__.
If you add a new function or class, there's no mechanism for
automatically adding that to the docs: you'll have to at least add a
line like ``.. autofunction:: <your function>`` in the appropriate
place. In many cases it's also nice to add some longer-form narrative
documentation around that.

We enable Sphinx's "nitpick mode", which turns dangling references
into an error – this helps catch typos. (This will be automatically
checked when your PR is submitted.) If you intentionally want to allow
a dangling reference, you can add it to the `nitpick_ignore
<http://www.sphinx-doc.org/en/stable/config.html#confval-nitpick_ignore>`__
whitelist in ``docs/source/conf.py``.

To build the docs locally, use our handy ``docs-requirements.txt``
file to install all of the required packages (possibly using a
virtualenv). After that, build the docs using ``make html`` in the
docs directory. The whole process might look something like this:

.. code-block:: text

    cd path/to/project/checkout/
    pip install -r docs-requirements.txt
    cd docs
    make html

You can then browse the docs using Python's builtin http server:
``python -m http.server 8000 --bind 127.0.0.1 --directory build/html``
and then opening ``http://127.0.0.1:8000/`` in your web browser.

.. _joining-the-team:

Joining the team
----------------

After your first PR is merged, you should receive a Github invitation
to join the ``python-trio`` organization. If you don't, that's not
your fault, it's because we made a mistake on our end. Give us a
nudge on chat or `send @njsmith an email <mailto:njs@pobox.com>`__ and
we'll fix it.

It's totally up to you whether you accept or not, and if you do
accept, you're welcome to participate as much or as little as you
want. We're offering the invitation because we'd love for you to join
us in making Python concurrency more friendly and robust, but there's
no pressure: life is too short to spend volunteer time on things that
you don't find fulfilling.

At this point people tend to have questions.

**How can you trust me with this kind of power? What if I mess
everything up?!?**

Relax, you got this! And we've got your back. Remember, it's just
software, and everything's in version control: worst case we'll just
roll things back and brainstorm ways to avoid the issue happening
again. We think it's more important to welcome people and help them
grow than to worry about the occasional minor mishap.

**I don't think I really deserve this.**

It's up to you, but we wouldn't be offering if we didn't think
you did.

**What exactly happens if I accept? Does it mean I'll break everything
if I click the wrong button?**

Concretely, if you accept the invitation, this does three things:

* It lets you manage incoming issues on all of the ``python-trio``
  projects by labelling them, closing them, etc.

* It lets you merge pull requests on all of the ``python-trio``
  projects by clicking Github's big green "Merge" button, but only if
  all their tests have passed.

* It automatically subscribes you to notifications on the
  ``python-trio`` repositories (but you can unsubscribe again if you
  want through the Github interface)

Note that it does *not* allow you to push changes directly to Github
without submitting a PR, and it doesn't let you merge broken PRs –
this is enforced through Github's "branch protection" feature, and it
applies to everyone from the newest contributor up to the project
founder.

**Okay, that's what I CAN do, but what SHOULD I do?**

Short answer: whatever you feel comfortable with.

We do have one rule, which is the same one most F/OSS projects use:
don't merge your own PRs. We find that having another person look at
each PR leads to better quality.

Beyond that, it all comes down to what you feel up to. If you don't
feel like you know enough to review a complex code change, then you
don't have to – you can just look it over and make some comments, even
if you don't feel up to making the final merge/no-merge decision. Or
you can just stick to merging trivial doc fixes and adding tags to
issues, that's helpful too. If after hanging around for a while you
start to feel like you have better handle on how things work and want
to start doing more, that's excellent; if it doesn't happen, that's
fine too.

If at any point you're unsure about whether doing something would be
appropriate, feel free to ask. For example, it's *totally OK* if the
first time you review a PR, you want someone else to check over your
work before you hit the merge button.

The best essay I know about reviewing pull request's is Sage Sharp's
`The gentle art of patch review
<http://sage.thesharps.us/2014/09/01/the-gentle-art-of-patch-review/>`__.
The `node.js guide
<https://github.com/nodejs/node/blob/master/doc/guides/contributing/pull-requests.md#reviewing-pull-requests>`__
also has some good suggestions, and `so does this blog post
<http://verraes.net/2013/10/pre-merge-code-reviews/>`__.


Managing issues
---------------

As issues come in, they need to be responded to, tracked, and –
hopefully! – eventually closed.

As a general rule, each open issue should represent some kind of task
that we need to do. Sometimes that task might be "figure out what to
do here", or even "figure out whether we want to address this issue";
sometimes it will be "answer this person's question". But if there's
no followup to be done, then the issue should be closed.


Issue labels
~~~~~~~~~~~~

The Trio repository in particular uses a number of labels to try and
keep track of issues. The current list is somewhat ad hoc, and may or
may not remain useful over time – if you think of a new label that
would be useful, a better name for an existing label, or think a label
has outlived its usefulness, then speak up.

* `good first issue
  <https://github.com/python-trio/trio/labels/good%20first%20issue>`__:
  Used to mark issues that are relatively straightforward, and could
  be good places for a new contributor to start.

* `todo soon
  <https://github.com/python-trio/trio/labels/todo%20soon>`__: This
  marks issues where there aren't questions left about whether or how
  to do it, it's just waiting for someone to dig in and do the work.

* `missing piece
  <https://github.com/python-trio/trio/labels/missing%20piece>`__:
  This generally marks significant self-contained chunks of missing
  functionality. If you're looking for a more ambitious project to
  work on, this might be useful.

* `potential API breaker
  <https://github.com/python-trio/trio/labels/potential%20API%20breaker>`__:
  What it says. This is useful because these are issues that we'll
  want to make sure to review aggressively as Trio starts to
  stabilize, and certainly before we reach 1.0.

* `design discussion
  <https://github.com/python-trio/trio/labels/design%20discussion>`__:
  This marks issues where there's significant design questions to be
  discussed; if you like meaty theoretical debates and discussions of
  API design, then browsing this might be interesting.

* `polish <https://github.com/python-trio/trio/labels/polish>`__:
  Marks issues that it'd be nice to resolve eventually, because it's
  the Right Thing To Do, but it's addressing a kind of edge case thing
  that isn't necessary for a minimum viable product. Sometimes
  overlaps with "user happiness".

* `user happiness
  <https://github.com/python-trio/trio/labels/user%20happiness>`__:
  From the name alone, this could apply to any bug (users certainly
  are happier when you fix bugs!), but that's not what we mean. This
  label is used for issues involving places where users stub their
  toes, or for the kinds of quality-of-life features that leave users
  surprised and excited – e.g. fancy testing tools that Just Work.


Governance
----------

`Nathaniel J. Smith <https://github.com/njsmith>`__ is the Trio `BDFL
<https://en.wikipedia.org/wiki/Benevolent_dictator_for_life>`__. If
the project grows to the point where we'd benefit from more structure,
then we'll figure something out.


.. Possible references for future additions:

   """
   Jumping into an unfamiliar codebase (or any for that matter) for the first time can be scary.
   Plus, if it's your first time contributing to open source, it can even be scarier!

   But, we at webpack believe:

       Any (even non-technical) individual should feel welcome to contribute.
       However you decide to contribute, it should be fun and enjoyable for you!
       Even after your first commit, you will walk away understanding more about webpack or JavaScript.
       Consequently, you could become a better developer, writer,
         designer, etc. along the way, and we are committed to helping
         foster this growth.
   """

   imposter syndrome disclaimer
   https://github.com/Unidata/MetPy#contributing

   checklist
   https://github.com/nayafia/contributing-template/blob/master/CONTRIBUTING-template.md

   https://medium.com/the-node-js-collection/healthy-open-source-967fa8be7951

   http://sweng.the-davies.net/Home/rustys-api-design-manifesto


================================================
FILE: docs/source/design.rst
================================================
Design and internals
====================

.. currentmodule:: trio

Here we'll discuss Trio's overall design and architecture: how it fits
together and why we made the decisions we did. If all you want to do
is use Trio, then you don't need to read this – though you might find
it interesting. The main target audience here is (a) folks who want to
read the code and potentially contribute, (b) anyone working on
similar libraries who want to understand what we're up to, (c) anyone
interested in I/O library design generally.

There are many valid approaches to writing an async I/O library. This
is ours.


High-level design principles
----------------------------

Trio's two overriding goals are **usability** and **correctness**: we
want to make it *easy* to get things *right*.

Of course there are lots of other things that matter too, like speed,
maintainability, etc. We want those too, as much as we can get. But
sometimes these things come in conflict, and when that happens, these
are our priorities.

In some sense the entire rest of this document is a description of how
these play out, but to give a simple example: Trio's
``KeyboardInterrupt`` handling machinery is a bit tricky and hard to
test, so it scores poorly on simplicity and maintainability. But we
think the usability+correctness gains outweigh this.

There are some subtleties here. Notice that it's specifically "easy to
get things right". There are situations (e.g. writing one-off scripts)
where the most "usable" tool is the one that will happily ignore
errors and keep going no matter what, or that doesn't bother with
resource cleanup. (Cf. the success of PHP.) This is a totally valid
use case and valid definition of usability, but it's not the one we
use: we think it's easier to build reliable and correct systems if
exceptions propagate until handled and if the system `catches you when
you make potentially dangerous resource handling errors
<https://github.com/python-trio/trio/issues/265>`__, so that's what we
optimize for.

It's also worth saying something about speed, since it often looms
large in comparisons between I/O libraries. This is a rather subtle
and complex topic.

In general, speed is certainly important – but the fact that people
sometimes use Python instead of C is a pretty good indicator that
usability often trumps speed in practice. We want to make Trio fast,
but it's not an accident that it's left off our list of overriding
goals at the top: if necessary we are willing to accept some slowdowns
in the service of usability and reliability.

To break things down in more detail:

First of all, there are the cases where speed directly impacts
correctness, like when you hit an accidental ``O(N**2)`` algorithm and
your program effectively locks up. Trio is very careful to use
algorithms and data structures that have good worst-case behavior
(even if this might mean sacrificing a few percentage points of speed
in the average case).

Similarly, when there's a conflict, we care more about 99th percentile
latencies than we do about raw throughput, because insufficient
throughput – if it's consistent! – can often be budgeted for and
handled with horizontal scaling, but once you lose latency it's gone
forever, and latency spikes can easily cross over to become a
correctness issue (e.g., an RPC server that responds slowly enough to
trigger timeouts is effectively non-functional). Again, of course,
this doesn't mean we don't care about throughput – but sometimes
engineering requires making trade-offs, especially for early-stage
projects that haven't had time to optimize for all use cases yet.

And finally: we care about speed on real-world applications quite a
bit, but speed on microbenchmarks is just about our lowest
priority. We aren't interested in competing to build "the fastest echo
server in the West". I mean, it's nice if it happens or whatever, and
microbenchmarks are an invaluable tool for understanding a system's
behavior. But if you play that game to win then it's very easy to get
yourself into a situation with seriously misaligned incentives, where
you have to start compromising on features and correctness in order to
get a speedup that's totally irrelevant to real-world applications. In
most cases (we suspect) it's the application code that's the
bottleneck, and you'll get more of a win out of running the whole app
under PyPy than out of any heroic optimizations to the I/O
layer. (And this is why Trio *does* place a priority on PyPy
compatibility.)

As a matter of tactics, we also note that at this stage in Trio's
lifecycle, it'd probably be a mistake to worry about speed too
much. It doesn't make sense to spend lots of effort optimizing an API
whose semantics are still in flux.


User-level API principles
-------------------------

Basic principles
~~~~~~~~~~~~~~~~

Trio is very much a continuation of the ideas explored in `this blog
post
<https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/>`__,
and in particular the `principles identified there
<https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#review-and-summing-up-what-is-async-await-native-anyway>`__
that make curio easier to use correctly than asyncio. So Trio also
adopts these rules, in particular:

* The only form of concurrency is the task.

* Tasks are guaranteed to run to completion.

* Task spawning is always explicit. No callbacks, no implicit
  concurrency, no futures/deferreds/promises/other APIs that involve
  callbacks. All APIs are `"causal"
  <https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#review-and-summing-up-what-is-async-await-native-anyway>`__
  except for those that are explicitly used for task spawning.

* Exceptions are used for error handling; ``try``/``finally``
  and ``with`` blocks for handling cleanup.


Cancel points and schedule points
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The first major place that Trio departs from curio is in its decision
to make a much larger fraction of the API use sync functions rather
than async functions, and to provide strong conventions about cancel
points and schedule points. (At this point, there are a lot of ways
that Trio and curio have diverged. But this was really the origin –
the tipping point where I realized that exploring these ideas would
require a new library, and couldn't be done inside curio.) The full
reasoning here takes some unpacking.

First, some definitions: a *cancel point* is a point where your code
checks if it has been cancelled – e.g., due to a timeout having
expired – and potentially raises a :exc:`Cancelled` error. A *schedule
point* is a point where the current task can potentially be suspended,
and another task allowed to run.

In curio, the convention is that all operations that interact with the
run loop in any way are syntactically async, and it's undefined which
of these operations are cancel/schedule points; users are instructed
to assume that any of them *might* be cancel/schedule points, but with
a few exceptions there's no guarantee that any of them are unless they
actually block. (I.e., whether a given call acts as a cancel/schedule
point is allowed to vary across curio versions and also depending on
runtime factors like network load.)

But when using an async library, there are good reasons why you need
to be aware of cancel and schedule points. They introduce a set of
complex and partially conflicting constraints on your code:

You need to make sure that every task passes through a cancel
point regularly, because otherwise timeouts become ineffective
and your code becomes subject to DoS attacks and other
problems. So for correctness, it's important to make sure you
have enough cancel points.

But... every cancel point also increases the chance of subtle
bugs in your program, because it's a place where you have to be
prepared to handle a :exc:`Cancelled` exception and clean up
properly. And while we try to make this as easy as possible,
these kinds of clean-up paths are notorious for getting missed
in testing and harboring subtle bugs. So the more cancel points
you have, the harder it is to make sure your code is correct.

Similarly, you need to make sure that every task passes through
a schedule point regularly, because otherwise this task could
end up hogging the event loop and preventing other code from
running, causing a latency spike. So for correctness, it's
important to make sure you have enough schedule points.

But... you have to be careful here too, because every schedule
point is a point where arbitrary other code could run, and
alter your program's state out from under you, introducing
classic concurrency bugs. So as you add more schedule points,
it `becomes exponentially harder to reason about how your code
is interleaved and be sure that it's correct
<https://glyph.twistedmatrix.com/2014/02/unyielding.html>`__.

So an important question for an async I/O library is: how do we help
the user manage these trade-offs?

Trio's answer is informed by two further observations:

First, any time a task blocks (e.g., because it does an ``await
sock.recv()`` but there's no data available to receive), that
has to be a cancel point (because if the I/O never arrives, we
need to be able to time out), and it has to be a schedule point
(because the whole idea of asynchronous programming is that
when one task is waiting we can switch to another task to get
something useful done).

And second, a function which sometimes counts as a cancel/schedule
point, and sometimes doesn't, is the worst of both worlds: you have
put in the effort to make sure your code handles cancellation or
interleaving correctly, but you can't count on it to help meet latency
requirements.

With all that in mind, Trio takes the following approach:

Rule 1: to reduce the number of concepts to keep track of, we collapse
cancel points and schedule points together. Every point that is a
cancel point is also a schedule point and vice versa. These are
distinct concepts both theoretically and in the actual implementation,
but we hide that distinction from the user so that there's only one
concept they need to keep track of.

Rule 2: Cancel+schedule points are determined *statically*. A Trio
primitive is either *always* a cancel+schedule point, or *never* a
cancel+schedule point, regardless of runtime conditions. This is
because we want it to be possible to determine whether some code has
"enough" cancel/schedule points by reading the source code.

In fact, to make this even simpler, we make it so you don't even have
to look at the function arguments: each *function* is either a
cancel+schedule point on *every* call or on *no* calls.

(Pragmatic exception: a Trio primitive is not required to act as a
cancel+schedule point when it raises an exception, even if it would
act as one in the case of a successful return. See `issue 474
<https://github.com/python-trio/trio/issues/474>`__ for more details;
basically, requiring checkpoints on all exception paths added a lot of
implementation complexity with negligible user-facing benefit.)

Observation: since blocking is always a cancel+schedule point, rule 2
implies that any function that *sometimes* blocks is *always* a
cancel+schedule point.

So that gives us a number of cancel+schedule points: all the functions
that can block. Are there any others? Trio's answer is: no. It's easy
to add new points explicitly (throw in a ``sleep(0)`` or whatever) but
hard to get rid of them when you don't want them. (And this is a real
issue – "too many potential cancel points" is definitely a tension
`I've felt
<https://github.com/dabeaz/curio/issues/149#issuecomment-269745283>`__
while trying to build things like task supervisors in curio.) And we
expect that most Trio programs will execute potentially-blocking
operations "often enough" to produce reasonable behavior. So, rule 3:
the *only* cancel+schedule points are the potentially-blocking
operations.

And now that we know where our cancel+schedule points are, there's the
question of how to effectively communicate this information to the
user. We want some way to mark out a category of functions that might
block or trigger a task switch, so that they're clearly distinguished
from functions that don't do this. Wouldn't it be nice if there were
some Python feature, that naturally divided functions into two
categories, and maybe put some sort of special syntactic marking on
with the functions that can do weird things like block and task
switch...? What a coincidence, that's exactly how async functions
work! Rule 4: in Trio, only the potentially blocking functions are
async. So e.g. :meth:`Event.wait` is async, but :meth:`Event.set` is
sync.

Summing up: out of what's actually a pretty vast space of design
possibilities, we declare by fiat that when it comes to Trio
primitives, all of these categories are identical:

* async functions
* functions that can, under at least some circumstances, block
* functions where the caller needs to be prepared to handle
  potential :exc:`Cancelled` exceptions
* functions that are guaranteed to notice any pending cancellation
* functions where you need to be prepared for a potential task switch
* functions that are guaranteed to take care of switching tasks if
  appropriate

This requires some non-trivial work internally – it actually takes a
fair amount of care to make those 4 cancel/schedule categories line
up, and there are some shenanigans required to let sync and async APIs
both interact with the run loop on an equal footing. But this is all
invisible to the user, we feel that it pays off in terms of usability
and correctness.

There is one exception to these rules, for async context
managers. Context managers are composed of two operations – enter and
exit – and sometimes only one of these is potentially
blocking. (Examples: ``async with lock:`` can block when entering but
never when exiting; ``async with open_nursery() as ...:`` can block
when exiting but never when entering.) But, Python doesn't have
"half-asynchronous" context managers: either both operations are
async-flavored, or neither is. In Trio we take a pragmatic approach:
for this kind of async context manager, we enforce the above rules
only on the potentially blocking operation, and the other operation is
allowed to be syntactically ``async`` but semantically
synchronous. And async context managers should always document which
of their operations are schedule+cancel points.


Exceptions always propagate
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Another rule that Trio follows is that *exceptions must always
propagate*. This is like the `zen
<https://www.python.org/dev/peps/pep-0020/>`__ line about "Errors
should never pass silently", except that in every other concurrency
library for Python (threads, asyncio, curio, ...), it's fairly common
to end up with an undeliverable exception, which just gets printed to
stderr and then discarded. While we understand the pragmatic
constraints that motivated these libraries to adopt this approach, we
feel that there are far too many situations where no human will ever
look at stderr and notice the problem, and insist that Trio APIs find
a way to propagate exceptions "up the stack" – whatever that might
mean.

This is often a challenging rule to follow – for example, the call
soon code has to jump through some hoops to make it happen – but its
most dramatic influence can seen in Trio's task-spawning interface,
where it motivates the use of "nurseries":

.. code-block:: python

   async def parent():
       async with trio.open_nursery() as nursery:
           nursery.start_soon(child)

(See :ref:`tasks` for full details.)

If you squint you can see the conceptual influence of Erlang's "task
linking" and "task tree" ideas here, though the details are different.

This design also turns out to enforce a remarkable, unexpected
invariant.

In `the blog post
<https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#c-c-c-c-causality-breaker>`__
I called out a nice feature of curio's spawning API, which is that
since spawning is the only way to break causality, and in curio
``spawn`` is async, which means that in curio sync functions are
guaranteed to be causal. One limitation though is that this invariant
is actually not very predictive: in curio there are lots of async
functions that could spawn off children and violate causality, but
most of them don't, but there's no clear marker for the ones that do.

Our API doesn't quite give that guarantee, but actually a better
one. In Trio:

* Sync functions can't create nurseries, because nurseries require an
  ``async with``

* Any async function can create a nursery and start new tasks... but
  creating a nursery *allows task starting but does not permit
  causality breaking*, because the children have to exit before the
  function is allowed to return. So we can preserve causality without
  having to give up concurrency!

* The only way to violate causality (which is an important feature,
  just one that needs to be handled carefully) is to explicitly create
  a nursery object in one task and then pass it into another task. And
  this provides a very clear and precise signal about where the funny
  stuff is happening – just watch for the nursery object getting
  passed around.


Introspection, debugging, testing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Tools for introspection and debugging are critical to achieving
usability and correctness in practice, so they should be first-class
considerations in Trio.

Similarly, the availability of powerful testing tools has a huge
impact on usability and correctness; we consider testing helpers to be
very much in scope for the Trio project.


Specific style guidelines
-------------------------

* As noted above, functions that don't block should be sync-colored,
  and functions that might block should be async-colored and
  unconditionally act as cancel+schedule points.

* Any function that takes a callable to run should have a signature
  like:

  .. code-block:: python

     def call_the_thing(fn, *args, kwonly1, kwonly2):
         ...

  where ``fn(*args)`` is the thing to be called, and ``kwonly1``,
  ``kwonly2``, are keyword-only arguments that belong to
  ``call_the_thing``. This applies even if ``call_the_thing`` doesn't
  take any arguments of its own, i.e. in this case its signature looks
  like:

  .. code-block:: python

     def call_the_thing(fn, *args):
         ...

  This allows users to skip faffing about with
  :func:`functools.partial` in most cases, while still providing an
  unambiguous and extensible way to pass arguments to the caller.
  (Hat-tip to asyncio, who we stole this convention from.)

* Whenever it makes sense, Trio classes should have a method called
  ``statistics()`` which returns an immutable object with named fields
  containing internal statistics about the object that are useful for
  debugging or introspection (:ref:`examples <synchronization>`).

* Functions or methods whose purpose is to wait for a condition to
  become true should be called ``wait_<condition>``. This avoids
  ambiguities like "does ``await readable()`` *check* readability
  (returning a bool) or *wait for* readability?".

  Sometimes this leads to the slightly funny looking ``await
  wait_...``. Sorry. As far as I can tell all the alternatives are
  worse, and you get used to the convention pretty quick.

* If it's desirable to have both blocking and non-blocking versions of
  a function, then they look like:

  .. code-block:: python

     async def OPERATION(arg1, arg2):
         ...

     def OPERATION_nowait(arg1, arg2):
         ...

  and the ``nowait`` version raises :exc:`trio.WouldBlock` if it would block.

* ...we should, but currently don't, have a solid convention to
  distinguish between functions that take an async callable and those
  that take a sync callable. See `issue #68
  <https://github.com/python-trio/trio/issues/68>`__.


A brief tour of Trio's internals
--------------------------------

If you want to understand how Trio is put together internally, then
the first thing to know is that there's a very strict internal
layering: the ``trio._core`` package is a fully self-contained
implementation of the core scheduling/cancellation/IO handling logic,
and then the other ``trio.*`` modules are implemented in terms of the
API it exposes. (If you want to see what this API looks like, then
``import trio; print(trio._core.__all__)``). Everything exported from
``trio._core`` is *also* exported as part of the ``trio``,
``trio.lowlevel``, or ``trio.testing`` namespaces. (See their
respective ``__init__.py`` files for details; there's a test to
enforce this.)

Rationale: currently, Trio is a new project in a novel part of the
design space, so we don't make any stability guarantees. But the goal
is to reach the point where we *can* declare the API stable. It's
unlikely that we'll be able to quickly explore all possible corners of
the design space and cover all possible types of I/O. So instead, our
strategy is to make sure that it's possible for independent packages
to add new features on top of Trio. Enforcing the ``trio`` vs
``trio._core`` split is a way of `eating our own dogfood
<https://en.wikipedia.org/wiki/Eating_your_own_dog_food>`__: basic
functionality like :class:`trio.Lock` and :mod:`trio.socket` is
actually implemented solely in terms of public APIs. And the hope is
that by doing this, we increase the chances that someone who comes up
with a better kind of queue or wants to add some new functionality
like, say, file system change watching, will be able to do that on top
of our public APIs without having to modify Trio internals.


Inside ``trio._core``
~~~~~~~~~~~~~~~~~~~~~

The ``_ki.py`` module implements the core infrastructure for safe handling
of :class:`KeyboardInterrupt`.  It's largely independent of the rest of Trio,
and could (possibly should?) be extracted into its own independent package.

The most important submodule, where everything is integrated, is
``_run.py``. (This is also by far the largest submodule; it'd be nice
to factor bits of it out where possible, but it's tricky because the
core functionality genuinely is pretty intertwined.) Notably, this is
where cancel scopes, nurseries, and :class:`~trio.lowlevel.Task` are
defined; it's also where the scheduler state and :func:`trio.run`
live.

The one thing that *isn't* in ``_run.py`` is I/O handling. This is
delegated to an ``IOManager`` class, of which there are currently
three implementations:

* ``EpollIOManager`` in ``_io_epoll.py`` (used on Linux, illumos)

* ``KqueueIOManager`` in ``_io_kqueue.py`` (used on macOS, \*BSD)

* ``WindowsIOManager`` in ``_io_windows.py`` (used on Windows)

The epoll and kqueue backends take advantage of the epoll and kqueue
wrappers in the stdlib :mod:`select` module. The windows backend uses
CFFI to access to the Win32 API directly (see
``trio/_core/_windows_cffi.py``). In general, we prefer to go directly
to the raw OS functionality rather than use :mod:`selectors`, for
several reasons:

* Controlling our own fate: I/O handling is pretty core to what Trio
  is about, and :mod:`selectors` is (as of 2017-03-01) somewhat buggy
  (e.g. `issue 29256 <https://bugs.python.org/issue29256>`__, `issue
  29255 <https://bugs.python.org/issue29255>`__). Which isn't a big
  deal on its own, but since :mod:`selectors` is part of the standard
  library we can't fix it and ship an updated version; we're stuck
  with whatever we get. We want more control over our users'
  experience than that.

* Impedance mismatch: the :mod:`selectors` API isn't particularly
  well-fitted to how we want to use it. For example, kqueue natively
  treats an interest in readability of some fd as a separate thing
  from an interest in that same fd's writability, which neatly matches
  Trio's model. :class:`selectors.KqueueSelector` goes to some effort
  internally to lump together all interests in a single fd, and to use
  it we'd then we'd have to jump through more hoops to reverse
  this. Of course, the native epoll API is fd-centric in the same way
  as the :mod:`selectors` API so we do still have to write code to
  jump through these hoops, but the point is that the :mod:`selectors`
  abstractions aren't providing a lot of extra value.

* (Most important) Access to raw platform capabilities:
  :mod:`selectors` is highly inadequate on Windows, and even on
  Unix-like systems it hides a lot of power (e.g. kqueue can do a lot
  more than just check fd readability/writability!).

The ``IOManager`` layer provides a fairly raw exposure of the capabilities
of each system, with public API functions that vary between different
backends. (This is somewhat inspired by how :mod:`os` works.) These
public APIs are then exported as part of :mod:`trio.lowlevel`, and
higher-level APIs like :mod:`trio.socket` abstract over these
system-specific APIs to provide a uniform experience.

Currently the choice of backend is made statically at import time, and
there is no provision for "pluggable" backends. The intuition here is
that we'd rather focus our energy on making one set of solid, official
backends that provide a high-quality experience out-of-the-box on all
supported systems.


================================================
FILE: docs/source/glossary.rst
================================================
:orphan:

.. _glossary:

********
Glossary
********

.. glossary::

   asynchronous file object
       This is an object with an API identical to a :term:`file object`, with
       the exception that all methods that do I/O are async functions.

       The main ways to create an asynchronous file object are by using the
       :func:`trio.open_file` function or the :meth:`trio.Path.open`
       method. See :ref:`async-file-io` for more details.


================================================
FILE: docs/source/history.rst
================================================
Release history
===============

.. currentmodule:: trio

.. towncrier release notes start

trio 0.33.0 (2026-02-14)
------------------------

Bugfixes
~~~~~~~~

- Start supporting Android's new ``"android"`` `sys.platform`. (`#3357 <https://github.com/python-trio/trio/issues/3357>`__)


Deprecations and removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- Both :class:`trio.testing.RaisesGroup` and :class:`trio.testing.Matcher` have been deprecated. Pytest alternatives ``pytest.RaisesGroup`` and ``pytest.RaisesExc`` (respectively) are considered correct replacement. (`#3326 <https://github.com/python-trio/trio/issues/3326>`__)


trio 0.32.0 (2025-10-31)
------------------------

Features
~~~~~~~~

- Allow `trio.CapacityLimiter` to have zero total_tokens. (`#3321 <https://github.com/python-trio/trio/issues/3321>`__)


Bugfixes
~~~~~~~~

- Fixed a bug where iterating over an ``@as_safe_channel``-derived ``ReceiveChannel``
  would raise `~trio.BrokenResourceError` if the channel was closed by another task.
  It now shuts down cleanly. (`#3331 <https://github.com/python-trio/trio/issues/3331>`__)
- `trio.lowlevel.Task.iter_await_frames` now works on completed tasks, by
  returning an empty list of frames if the underlying coroutine has been closed.
  Previously, it raised an internal error. (`#3337 <https://github.com/python-trio/trio/issues/3337>`__)


Removals without deprecations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Drop support for Python 3.9. (`#3345 <https://github.com/python-trio/trio/issues/3345>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Decrease indentation for exception groups raised in `trio.as_safe_channel`. (`#3332 <https://github.com/python-trio/trio/issues/3332>`__)


Trio 0.31.0 (2025-09-09)
------------------------

Features
~~~~~~~~

- :exc:`Cancelled` strings can now display the source and reason for a cancellation. Trio-internal sources of cancellation will set this string, and :meth:`CancelScope.cancel` now has a ``reason`` string parameter that can be used to attach info to any :exc:`Cancelled` to help in debugging. (`#3232 <https://github.com/python-trio/trio/issues/3232>`__)


Bugfixes
~~~~~~~~

- Make ctrl+c work in more situations in the Trio REPL (``python -m trio``). (`#3007 <https://github.com/python-trio/trio/issues/3007>`__)
- Allow pickling `trio.Cancelled`, as they can show up when you want to pickle something else. This does not rule out pickling other ``NoPublicConstructor`` objects -- create an issue if necessary. (`#3248 <https://github.com/python-trio/trio/issues/3248>`__)
- Decrease import time on Windows by around 10%. (`#3263 <https://github.com/python-trio/trio/issues/3263>`__)
- Handle unwrapping SystemExit/KeyboardInterrupt exception gracefully in utility function ``raise_single_exception_from_group`` that reraises last exception from group. (`#3275 <https://github.com/python-trio/trio/issues/3275>`__)
- Ensure that the DTLS server does not mutate SSL context. (`#3277 <https://github.com/python-trio/trio/issues/3277>`__)
- Avoid having `trio.as_safe_channel` raise if closing the generator wrapped
  `GeneratorExit` in a `BaseExceptionGroup`. (`#3324 <https://github.com/python-trio/trio/issues/3324>`__)


Deprecations and removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- Implement ``bool(trio.Event)`` and have it raise a `DeprecationWarning` and tell users to use `trio.Event.is_set` instead. This is an alternative to ``mypy --enable-error-code=truthy-bool`` for users who don't use type checking. (`#3322 <https://github.com/python-trio/trio/issues/3322>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- When misnesting nurseries you now get a helpful :exc:`RuntimeError` instead of a catastrophic :exc:`TrioInternalError`. (`#3307 <https://github.com/python-trio/trio/issues/3307>`__)


Trio 0.30.0 (2025-04-20)
------------------------

Features
~~~~~~~~

- Add :func:`@trio.as_safe_channel <trio.as_safe_channel>`, a wrapper that can be used to make async generators safe.
  This will be the suggested fix for the flake8-async lint rule `ASYNC900 <https://flake8-async.readthedocs.io/en/latest/rules.html#async900>`_. (`#3197 <https://github.com/python-trio/trio/issues/3197>`__)


Bugfixes
~~~~~~~~

- Allow `trio` to be a `types.ModuleType` and still have deprecated attributes. (`#2135 <https://github.com/python-trio/trio/issues/2135>`__)
- Fixed socket module for some older systems which lack ``socket.AI_NUMERICSERV``.
  Now trio works on legacy (pre-Lion) macOS. (`#3133 <https://github.com/python-trio/trio/issues/3133>`__)
- Update type hints for `trio.run_process` and `trio.lowlevel.open_process`. (`#3183 <https://github.com/python-trio/trio/issues/3183>`__)
- Don't mutate the global runner when MockClock is created. (`#3205 <https://github.com/python-trio/trio/issues/3205>`__)
- Fix incorrect return type hint for :meth:`Nursery.start() <trio.Nursery.start>`. (`#3224 <https://github.com/python-trio/trio/issues/3224>`__)


Improved documentation
~~~~~~~~~~~~~~~~~~~~~~

- Update wording in documentation to more accurately reflect Trio's maturity. (`#3216 <https://github.com/python-trio/trio/issues/3216>`__)


Trio 0.29.0 (2025-02-14)
------------------------

Features
~~~~~~~~

- Add :func:`trio.lowlevel.in_trio_run` and :func:`trio.lowlevel.in_trio_task` and document the semantics (and differences) thereof. See :ref:`the documentation <trio_contexts>`. (`#2757 <https://github.com/python-trio/trio/issues/2757>`__)
- If `trio.testing.RaisesGroup` does not get the expected exceptions it now raises an `AssertionError` with a helpful message, instead of letting the raised exception/group fall through. The raised exception is available in the ``__context__`` of the `AssertionError` and can be seen in the traceback. (`#3145 <https://github.com/python-trio/trio/issues/3145>`__)


Bugfixes
~~~~~~~~

- Clear Trio's cache of worker threads upon `os.fork`. (`#2764 <https://github.com/python-trio/trio/issues/2764>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Stop using ctypes to mutate tracebacks for ``strict_exception_groups=False``'s exception collapsing. (`#405 <https://github.com/python-trio/trio/issues/405>`__)
- Fixed spelling error in Windows error code enum for ``ERROR_INVALID_PARAMETER``. (`#3166 <https://github.com/python-trio/trio/issues/3166>`__)
- Publicly re-export ``__version__`` for type checking purposes. (`#3186 <https://github.com/python-trio/trio/issues/3186>`__)
- The typing of :func:`trio.abc.HostnameResolver.getaddrinfo` has been corrected to
  match that of the stdlib `socket.getaddrinfo`, which was updated in mypy 1.15 (via
  a typeshed update) to include the possibility of ``tuple[int, bytes]`` for the
  ``sockaddr`` field of the result. This happens in situations where Python was compiled
  with ``--disable-ipv6``.

  Additionally, the static typing of :func:`trio.to_thread.run_sync`,
  :func:`trio.from_thread.run` and :func:`trio.from_thread.run_sync` has been
  improved and should reflect the underlying function being run. (`#3201 <https://github.com/python-trio/trio/issues/3201>`__)


Trio 0.28.0 (2024-12-25)
------------------------

Bugfixes
~~~~~~~~

- :func:`inspect.iscoroutinefunction` and the like now give correct answers when
  called on KI-protected functions. (`#2670 <https://github.com/python-trio/trio/issues/2670>`__)
- Rework KeyboardInterrupt protection to track code objects, rather than frames,
  as protected or not. The new implementation no longer needs to access
  ``frame.f_locals`` dictionaries, so it won't artificially extend the lifetime of
  local variables. Since KeyboardInterrupt protection is now imposed statically
  (when a protected function is defined) rather than each time the function runs,
  its previously-noticeable performance overhead should now be near zero.
  The lack of a call-time wrapper has some other benefits as well:

  * :func:`inspect.iscoroutinefunction` and the like now give correct answers when
    called on KI-protected functions.

  * Calling a synchronous KI-protected function no longer pushes an additional stack
    frame, so tracebacks are clearer.

  * A synchronous KI-protected function invoked from C code (such as a weakref
    finalizer) is now guaranteed to start executing; previously there would be a brief
    window in which KeyboardInterrupt could be raised before the protection was
    established.

  One minor drawback of the new approach is that multiple instances of the same
  closure share a single KeyboardInterrupt protection state (because they share a
  single code object). That means that if you apply
  `@enable_ki_protection <trio.lowlevel.enable_ki_protection>` to some of them
  and not others, you won't get the protection semantics you asked for. See the
  documentation of `@enable_ki_protection <trio.lowlevel.enable_ki_protection>`
  for more details and a workaround. (`#3108 <https://github.com/python-trio/trio/issues/3108>`__)
- Rework foreign async generator finalization to track async generator
  ids rather than mutating ``ag_frame.f_locals``. This fixes an issue
  with the previous implementation: locals' lifetimes will no longer be
  extended by materialization in the ``ag_frame.f_locals`` dictionary that
  the previous finalization dispatcher logic needed to access to do its work. (`#3112 <https://github.com/python-trio/trio/issues/3112>`__)
- Ensure that Pyright recognizes our underscore prefixed attributes for attrs classes. (`#3114 <https://github.com/python-trio/trio/issues/3114>`__)
- Fix `trio.testing.RaisesGroup`'s typing. (`#3141 <https://github.com/python-trio/trio/issues/3141>`__)


Improved documentation
~~~~~~~~~~~~~~~~~~~~~~

- Improve error message when run after gevent's monkey patching. (`#3087 <https://github.com/python-trio/trio/issues/3087>`__)
- Document that :func:`trio.sleep_forever` is guaranteed to raise an exception now. (`#3113 <https://github.com/python-trio/trio/issues/3113>`__)


Removals without deprecations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Remove workaround for OpenSSL 1.1.1 DTLS ClientHello bug. (`#3097 <https://github.com/python-trio/trio/issues/3097>`__)
- Drop support for Python 3.8. (`#3104 <https://github.com/python-trio/trio/issues/3104>`__) (`#3106 <https://github.com/python-trio/trio/issues/3106>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Switch to using :pep:`570` for positional-only arguments for `~trio.socket.SocketType`'s methods. (`#3094 <https://github.com/python-trio/trio/issues/3094>`__)
- Improve type annotations in several places by removing `Any` usage. (`#3121 <https://github.com/python-trio/trio/issues/3121>`__)
- Get and enforce 100% coverage (`#3159 <https://github.com/python-trio/trio/issues/3159>`__)


Trio 0.27.0 (2024-10-17)
------------------------

Breaking changes
~~~~~~~~~~~~~~~~

- :func:`trio.move_on_after` and :func:`trio.fail_after` previously set the deadline relative to initialization time, instead of more intuitively upon entering the context manager. This might change timeouts if a program relied on this behavior. If you want to restore previous behavior you should instead use ``trio.move_on_at(trio.current_time() + ...)``.
  flake8-async has a new rule to catch this, in case you're supporting older trio versions. See :ref:`ASYNC122`. (`#2512 <https://github.com/python-trio/trio/issues/2512>`__)


Features
~~~~~~~~

- :meth:`CancelScope.relative_deadline` and :meth:`CancelScope.is_relative` added, as well as a ``relative_deadline`` parameter to ``__init__``. This allows initializing scopes ahead of time, but where the specified relative deadline doesn't count down until the scope is entered. (`#2512 <https://github.com/python-trio/trio/issues/2512>`__)
- :class:`trio.Lock` and :class:`trio.StrictFIFOLock` will now raise :exc:`trio.BrokenResourceError` when :meth:`trio.Lock.acquire` would previously stall due to the owner of the lock exiting without releasing the lock. (`#3035 <https://github.com/python-trio/trio/issues/3035>`__)
- `trio.move_on_at`, `trio.move_on_after`, `trio.fail_at` and `trio.fail_after` now accept *shield* as a keyword argument. If specified, it provides an initial value for the `~trio.CancelScope.shield` attribute of the `trio.CancelScope` object created by the context manager. (`#3052 <https://github.com/python-trio/trio/issues/3052>`__)
- Added :func:`trio.lowlevel.add_parking_lot_breaker` and :func:`trio.lowlevel.remove_parking_lot_breaker` to allow creating custom lock/semaphore implementations that will break their underlying parking lot if a task exits unexpectedly. :meth:`trio.lowlevel.ParkingLot.break_lot` is also added, to allow breaking a parking lot intentionally. (`#3081 <https://github.com/python-trio/trio/issues/3081>`__)


Bugfixes
~~~~~~~~

- Allow sockets to bind any ``os.PathLike`` object. (`#3041 <https://github.com/python-trio/trio/issues/3041>`__)
- Update ``trio.lowlevel.open_process``'s documentation to allow bytes. (`#3076 <https://github.com/python-trio/trio/issues/3076>`__)
- Update :func:`trio.sleep_forever` to be `NoReturn`. (`#3095 <https://github.com/python-trio/trio/issues/3095>`__)


Improved documentation
~~~~~~~~~~~~~~~~~~~~~~

- Add docstrings for memory channels' ``statistics()`` and ``aclose`` methods. (`#3101 <https://github.com/python-trio/trio/issues/3101>`__)


Trio 0.26.2 (2024-08-08)
------------------------

Bugfixes
~~~~~~~~

- Remove remaining ``hash`` usage and fix test configuration issue that prevented it from being caught. (`#3053 <https://github.com/python-trio/trio/issues/3053>`__)


Trio 0.26.1 (2024-08-05)
------------------------

Bugfixes
~~~~~~~~

- Switched ``attrs`` usage off of ``hash``, which is now deprecated. (`#3053 <https://github.com/python-trio/trio/issues/3053>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Use PyPI's Trusted Publishers to make releases. (`#2980 <https://github.com/python-trio/trio/issues/2980>`__)


Trio 0.26.0 (2024-07-05)
------------------------

Features
~~~~~~~~

- Added an interactive interpreter ``python -m trio``.

  This makes it easier to try things and experiment with trio in the a Python repl.
  Use the ``await`` keyword without needing to call ``trio.run()``

  .. code-block:: console

     $ python -m trio
     Trio 0.21.0+dev, Python 3.10.6
     Use "await" directly instead of "trio.run()".
     Type "help", "copyright", "credits" or "license" for more information.
     >>> import trio
     >>> await trio.sleep(1); print("hi")  # prints after one second
     hi

  See :ref:`interactive debugging` for further detail. (`#2972 <https://github.com/python-trio/trio/issues/2972>`__)
- :class:`trio.testing.RaisesGroup` can now catch an unwrapped exception with ``unwrapped=True``. This means that the behaviour of :ref:`except* <except_star>` can be fully replicated in combination with ``flatten_subgroups=True`` (formerly ``strict=False``). (`#2989 <https://github.com/python-trio/trio/issues/2989>`__)


Bugfixes
~~~~~~~~

- Fixed a bug where :class:`trio.testing.RaisesGroup(..., strict=False) <trio.testing.RaisesGroup>` would check the number of exceptions in the raised `ExceptionGroup` before flattening subgroups, leading to incorrectly failed matches.
  It now properly supports end (``$``) regex markers in the ``match`` message, by no longer including " (x sub-exceptions)" in the string it matches against. (`#2989 <https://github.com/python-trio/trio/issues/2989>`__)


Deprecations and removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- Deprecated ``strict`` parameter from :class:`trio.testing.RaisesGroup`, previous functionality of ``strict=False`` is now in ``flatten_subgroups=True``. (`#2989 <https://github.com/python-trio/trio/issues/2989>`__)


Trio 0.25.1 (2024-05-16)
------------------------

Bugfixes
~~~~~~~~

- Fix crash when importing trio in embedded Python on Windows, and other installs that remove docstrings. (`#2987 <https://github.com/python-trio/trio/issues/2987>`__)


Trio 0.25.0 (2024-03-17)
------------------------

Breaking changes
~~~~~~~~~~~~~~~~

- The :ref:`strict_exception_groups <strict_exception_groups>` parameter now defaults to `True` in `trio.run` and `trio.lowlevel.start_guest_run`. `trio.open_nursery` still defaults to the same value as was specified in `trio.run`/`trio.lowlevel.start_guest_run`, but if you didn't specify it there then all subsequent calls to `trio.open_nursery` will change.
  This is unfortunately very tricky to change with a deprecation period, as raising a `DeprecationWarning` whenever :ref:`strict_exception_groups <strict_exception_groups>` is not specified would raise a lot of unnecessary warnings.

  Notable side effects of changing code to run with ``strict_exception_groups==True``

  * If an iterator raises `StopAsyncIteration` or `StopIteration` inside a nursery, then python will not recognize wrapped instances of those for stopping iteration.
  * `trio.run_process` is now documented that it can raise an `ExceptionGroup`. It previously could do this in very rare circumstances, but with :ref:`strict_exception_groups <strict_exception_groups>` set to `True` it will now do so whenever exceptions occur in ``deliver_cancel`` or with problems communicating with the subprocess.

    * Errors in opening the process is now done outside the internal nursery, so if code previously ran with ``strict_exception_groups=True`` there are cases now where an `ExceptionGroup` is *no longer* added.
  * `trio.TrioInternalError` ``.__cause__`` might be wrapped in one or more `ExceptionGroups <ExceptionGroup>` (`#2786 <https://github.com/python-trio/trio/issues/2786>`__)


Features
~~~~~~~~

- Add `trio.testing.wait_all_threads_completed`, which blocks until no threads are running tasks. This is intended to be used in the same way as `trio.testing.wait_all_tasks_blocked`. (`#2937 <https://github.com/python-trio/trio/issues/2937>`__)
- :class:`Path` is now a subclass of :class:`pathlib.PurePath`, allowing it to interoperate with other standard
  :mod:`pathlib` types.

  Instantiating :class:`Path` now returns a concrete platform-specific subclass, one of :class:`PosixPath` or
  :class:`WindowsPath`, matching the behavior of :class:`pathlib.Path`. (`#2959 <https://github.com/python-trio/trio/issues/2959>`__)


Bugfixes
~~~~~~~~

- The pthread functions are now correctly found on systems using vanilla versions of musl libc. (`#2939 <https://github.com/python-trio/trio/issues/2939>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- use the regular readme for the PyPI long_description (`#2866 <https://github.com/python-trio/trio/issues/2866>`__)


Trio 0.24.0 (2024-01-10)
------------------------

Features
~~~~~~~~

- New helper classes: :class:`~.testing.RaisesGroup` and :class:`~.testing.Matcher`.

  In preparation for changing the default of ``strict_exception_groups`` to `True`, we're introducing a set of helper classes that can be used in place of `pytest.raises <https://docs.pytest.org/en/stable/reference/reference.html#pytest.raises>`_ in tests, to check for an expected `ExceptionGroup`.
  These are provisional, and only planned to be supplied until there's a good solution in ``pytest``. See https://github.com/pytest-dev/pytest/issues/11538 (`#2785 <https://github.com/python-trio/trio/issues/2785>`__)


Deprecations and removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- ``MultiError`` has been fully removed, and all relevant trio functions now raise ExceptionGroups instead. This should not affect end users that have transitioned to using ``except*`` or catching ExceptionGroup/BaseExceptionGroup. (`#2891 <https://github.com/python-trio/trio/issues/2891>`__)


Trio 0.23.2 (2023-12-14)
------------------------

Features
~~~~~~~~

- `TypeVarTuple <https://docs.python.org/3.12/library/typing.html#typing.TypeVarTuple>`_ is now used to fully type :meth:`nursery.start_soon() <trio.Nursery.start_soon>`, :func:`trio.run`, :func:`trio.to_thread.run_sync`, and other similar functions accepting ``(func, *args)``. This means type checkers will be able to verify types are used correctly. :meth:`nursery.start() <trio.Nursery.start>` is not fully typed yet however. (`#2881 <https://github.com/python-trio/trio/issues/2881>`__)


Bugfixes
~~~~~~~~

- Make pyright recognize :func:`open_memory_channel` as generic. (`#2873 <https://github.com/python-trio/trio/issues/2873>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Moved the metadata into :pep:`621`-compliant :file:`pyproject.toml`. (`#2860 <https://github.com/python-trio/trio/issues/2860>`__)
- do not depend on exceptiongroup pre-release (`#2861 <https://github.com/python-trio/trio/issues/2861>`__)
- Move .coveragerc into pyproject.toml (`#2867 <https://github.com/python-trio/trio/issues/2867>`__)


Trio 0.23.1 (2023-11-04)
------------------------

Bugfixes
~~~~~~~~

- Don't crash on import in Anaconda interpreters. (`#2855 <https://github.com/python-trio/trio/issues/2855>`__)


Trio 0.23.0 (2023-11-03)
------------------------

Headline features
~~~~~~~~~~~~~~~~~

- Add type hints. (`#543 <https://github.com/python-trio/trio/issues/543>`__)


Features
~~~~~~~~

- When exiting a nursery block, the parent task always waits for child
  tasks to exit. This wait cannot be cancelled. However, previously, if
  you tried to cancel it, it *would* inject a `Cancelled` exception,
  even though it wasn't cancelled. Most users probably never noticed
  either way, but injecting a `Cancelled` here is not really useful, and
  in some rare cases caused confusion or problems, so Trio no longer
  does that. (`#1457 <https://github.com/python-trio/trio/issues/1457>`__)
- If called from a thread spawned by `trio.to_thread.run_sync`, `trio.from_thread.run` and
  `trio.from_thread.run_sync` now reuse the task and cancellation status of the host task;
  this means that context variables and cancel scopes naturally propagate 'through'
  threads spawned by Trio. You can also use `trio.from_thread.check_cancelled`
  to efficiently check for cancellation without reentering the Trio thread. (`#2392 <https://github.com/python-trio/trio/issues/2392>`__)
- :func:`trio.lowlevel.start_guest_run` now does a bit more setup of the guest run
  before it returns to its caller, so that the caller can immediately make calls to
  :func:`trio.current_time`, :func:`trio.lowlevel.spawn_system_task`,
  :func:`trio.lowlevel.current_trio_token`, etc. (`#2696 <https://github.com/python-trio/trio/issues/2696>`__)


Bugfixes
~~~~~~~~

- When a starting function raises before calling :func:`trio.TaskStatus.started`,
  :func:`trio.Nursery.start` will no longer wrap the exception in an undocumented
  :exc:`ExceptionGroup`. Previously, :func:`trio.Nursery.start` would incorrectly
  raise an :exc:`ExceptionGroup` containing it when using ``trio.run(...,
  strict_exception_groups=True)``. (`#2611 <https://github.com/python-trio/trio/issues/2611>`__)


Deprecations and removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- To better reflect the underlying thread handling semantics,
  the keyword argument for `trio.to_thread.run_sync` that was
  previously called ``cancellable`` is now named ``abandon_on_cancel``.
  It still does the same thing -- allow the thread to be abandoned
  if the call to `trio.to_thread.run_sync` is cancelled -- but since we now
  have other ways to propagate a cancellation without abandoning
  the thread, "cancellable" has become somewhat of a misnomer.
  The old ``cancellable`` name is now deprecated. (`#2841 <https://github.com/python-trio/trio/issues/2841>`__)
- Deprecated support for ``math.inf`` for the ``backlog`` argument in ``open_tcp_listeners``, making its docstring correct in the fact that only ``TypeError`` is raised if invalid arguments are passed. (`#2842 <https://github.com/python-trio/trio/issues/2842>`__)


Removals without deprecations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Drop support for Python3.7 and PyPy3.7/3.8. (`#2668 <https://github.com/python-trio/trio/issues/2668>`__)
- Removed special ``MultiError`` traceback handling for IPython. As of `version 8.15 <https://ipython.readthedocs.io/en/stable/whatsnew/version8.html#ipython-8-15>`_ `ExceptionGroup` is handled natively. (`#2702 <https://github.com/python-trio/trio/issues/2702>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Trio now indicates its presence to `sniffio` using the ``sniffio.thread_local``
  interface that is preferred since sniffio v1.3.0. This should be less likely
  than the previous approach to cause :func:`sniffio.current_async_library` to
  return incorrect results due to unintended inheritance of contextvars. (`#2700 <https://github.com/python-trio/trio/issues/2700>`__)
- On windows, if SIO_BASE_HANDLE failed and SIO_BSP_HANDLE_POLL didn't return a different socket, runtime error will now raise from the OSError that indicated the issue so that in the event it does happen it might help with debugging. (`#2807 <https://github.com/python-trio/trio/issues/2807>`__)


Trio 0.22.2 (2023-07-13)
------------------------

Bugfixes
~~~~~~~~

- Fix ``PermissionError`` when importing `trio` due to trying to access ``pthread``. (`#2688 <https://github.com/python-trio/trio/issues/2688>`__)


Trio 0.22.1 (2023-07-02)
------------------------

Breaking changes
~~~~~~~~~~~~~~~~

- Timeout functions now raise `ValueError` if passed `math.nan`. This includes `trio.sleep`, `trio.sleep_until`, `trio.move_on_at`, `trio.move_on_after`, `trio.fail_at` and `trio.fail_after`. (`#2493 <https://github.com/python-trio/trio/issues/2493>`__)


Features
~~~~~~~~

- Added support for naming threads created with `trio.to_thread.run_sync`, requires pthreads so is only available on POSIX platforms with glibc installed. (`#1148 <https://github.com/python-trio/trio/issues/1148>`__)
- `trio.socket.socket` now prints the address it tried to connect to upon failure. (`#1810 <https://github.com/python-trio/trio/issues/1810>`__)


Bugfixes
~~~~~~~~

- Fixed a crash that can occur when running Trio within an embedded Python interpreter, by handling the `TypeError` that is raised when trying to (re-)install a C signal handler. (`#2333 <https://github.com/python-trio/trio/issues/2333>`__)
- Fix :func:`sniffio.current_async_library` when Trio tasks are spawned from a non-Trio context (such as when using trio-asyncio). Previously, a regular Trio task would inherit the non-Trio library name, and spawning a system task would cause the non-Trio caller to start thinking it was Trio. (`#2462 <https://github.com/python-trio/trio/issues/2462>`__)
- Issued a new release as in the git tag for 0.22.0, ``trio.__version__`` is incorrectly set to 0.21.0+dev. (`#2485 <https://github.com/python-trio/trio/issues/2485>`__)


Improved documentation
~~~~~~~~~~~~~~~~~~~~~~

- Documented that :obj:`Nursery.start_soon` does not guarantee task ordering. (`#970 <https://github.com/python-trio/trio/issues/970>`__)


Trio 0.22.0 (2022-09-28)
------------------------

Headline features
~~~~~~~~~~~~~~~~~

- ``MultiError`` has been deprecated in favor of the standard :exc:`BaseExceptionGroup`
  (introduced in :pep:`654`). On Python versions below 3.11, this exception and its
  derivative :exc:`ExceptionGroup` are provided by the backport_. Trio still raises
  ``MultiError``, but it has been refactored into a subclass of :exc:`BaseExceptionGroup`
  which users should catch instead of ``MultiError``. Uses of the ``MultiError.filter()``
  class method should be replaced with :meth:`BaseExceptionGroup.split`. Uses of the
  ``MultiError.catch()`` class method should be replaced with either ``except*`` clauses
  (on Python 3.11+) or the ``exceptiongroup.catch()`` context manager provided by the
  backport_.

  See the :ref:`updated documentation <exceptiongroups>` for details.
  (`#2211 <https://github.com/python-trio/trio/issues/2211>`__)

  .. _backport: https://pypi.org/project/exceptiongroup/


Features
~~~~~~~~

- Added support for `Datagram TLS
  <https://en.wikipedia.org/wiki/Datagram_Transport_Layer_Security>`__,
  for secure communication over UDP. Currently requires `PyOpenSSL
  <https://pypi.org/p/pyopenssl>`__. (`#2010 <https://github.com/python-trio/trio/issues/2010>`__)


Trio 0.21.0 (2022-06-07)
----------------------------

Features
~~~~~~~~

- Trio now supports Python 3.11. (`#2270
  <https://github.com/python-trio/trio/issues/2270>`__, `#2318
  <https://github.com/python-trio/trio/issues/2318>`__, `#2319
  <https://github.com/python-trio/trio/issues/2319>`__)

Deprecations and Removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- Remove support for Python 3.6. (`#2210 <https://github.com/python-trio/trio/issues/2210>`__)


Trio 0.20.0 (2022-02-21)
------------------------

Features
~~~~~~~~

- You can now conveniently spawn a child process in a background task
  and interact it with on the fly using ``process = await
  nursery.start(run_process, ...)``. See `run_process` for more details.
  We recommend most users switch to this new API. Also note that:

  - ``trio.open_process`` has been deprecated in favor of
    `trio.lowlevel.open_process`,
  - The ``aclose`` method on `Process` has been deprecated along with
    ``async with process_obj``. (`#1104 <https://github.com/python-trio/trio/issues/1104>`__)
- Now context variables set with `contextvars` are preserved when running functions
  in a worker thread with `trio.to_thread.run_sync`, or when running
  functions from the worker thread in the parent Trio thread with
  `trio.from_thread.run`, and `trio.from_thread.run_sync`.
  This is done by automatically copying the `contextvars` context.
  `trio.lowlevel.spawn_system_task` now also receives an optional ``context`` argument. (`#2160 <https://github.com/python-trio/trio/issues/2160>`__)


Bugfixes
~~~~~~~~

- Trio now avoids creating cyclic garbage when a ``MultiError`` is generated and
  filtered, including invisibly within the cancellation system. This means errors raised
  through nurseries and cancel scopes should result in less GC latency. (`#2063 <https://github.com/python-trio/trio/issues/2063>`__)
- Trio now deterministically cleans up file descriptors that were opened before
  subprocess creation fails. Previously, they would remain open until the next run of
  the garbage collector. (`#2193 <https://github.com/python-trio/trio/issues/2193>`__)
- Add compatibility with OpenSSL 3.0 on newer Python and PyPy versions by working
  around ``SSLEOFError`` not being raised properly. (`#2203 <https://github.com/python-trio/trio/issues/2203>`__)
- Fix a bug that could cause `Process.wait` to hang on Linux systems using pidfds, if
  another task were to access `Process.returncode` after the process exited but before
  ``wait`` woke up (`#2209 <https://github.com/python-trio/trio/issues/2209>`__)


Trio 0.19.0 (2021-06-15)
------------------------

Features
~~~~~~~~

- Trio now supports Python 3.10. (`#1921 <https://github.com/python-trio/trio/issues/1921>`__)
- Use slots for :class:`~.lowlevel.Task` which should make them slightly smaller and faster. (`#1927 <https://github.com/python-trio/trio/issues/1927>`__)
- Make :class:`~.Event` more lightweight by using less objects (about 2 rather
  than 5, including a nested ParkingLot and attribute dicts) and simpler
  structures (set rather than OrderedDict).  This may benefit applications that
  create a large number of event instances, such as with the "replace event
  object on every set()" idiom. (`#1948 <https://github.com/python-trio/trio/issues/1948>`__)


Bugfixes
~~~~~~~~

- The event loop now holds on to references of coroutine frames for only
  the minimum necessary period of time. (`#1864 <https://github.com/python-trio/trio/issues/1864>`__)
- The :class:`~.lowlevel.TrioToken` class can now be used as a target of a weak reference. (`#1924 <https://github.com/python-trio/trio/issues/1924>`__)


Trio 0.18.0 (2021-01-11)
------------------------

Features
~~~~~~~~

- Add synchronous ``.close()`` methods and context manager (``with x``) support
  for `.MemorySendChannel` and `.MemoryReceiveChannel`. (`#1797 <https://github.com/python-trio/trio/issues/1797>`__)


Bugfixes
~~~~~~~~

- Previously, on Windows, Trio programs using thousands of sockets at the same time could trigger extreme slowdowns in the Windows kernel. Now, Trio works around this issue, so you should be able to use as many sockets as you want. (`#1280 <https://github.com/python-trio/trio/issues/1280>`__)
- :func:`trio.from_thread.run` no longer crashes the Trio run if it is
  executed after the system nursery has been closed but before the run
  has finished. Calls made at this time will now raise
  `trio.RunFinishedError`.  This fixes a regression introduced in
  Trio 0.17.0.  The window in question is only one scheduler tick long in
  most cases, but may be longer if async generators need to be cleaned up. (`#1738 <https://github.com/python-trio/trio/issues/1738>`__)
- Fix a crash in pypy-3.7 (`#1765 <https://github.com/python-trio/trio/issues/1765>`__)
- Trio now avoids creating cyclic garbage as often. This should have a
  minimal impact on most programs, but can slightly reduce how often the
  cycle collector GC runs on CPython, which can reduce latency spikes. (`#1770 <https://github.com/python-trio/trio/issues/1770>`__)


Deprecations and removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- Remove deprecated ``max_refill_bytes`` from :class:`SSLStream`. (`#959 <https://github.com/python-trio/trio/issues/959>`__)
- Remove the deprecated ``tiebreaker`` argument to `trio.testing.wait_all_tasks_blocked`. (`#1558 <https://github.com/python-trio/trio/issues/1558>`__)
- Remove the deprecated ``trio.hazmat`` module. (`#1722 <https://github.com/python-trio/trio/issues/1722>`__)
- Stop allowing subclassing public classes. This behavior was deprecated in 0.15.0. (`#1726 <https://github.com/python-trio/trio/issues/1726>`__)


Trio 0.17.0 (2020-09-15)
------------------------

Headline features
~~~~~~~~~~~~~~~~~

- Trio now supports automatic :ref:`async generator finalization
  <async-generators>`, so more async generators will work even if you
  don't wrap them in ``async with async_generator.aclosing():``
  blocks. Please see the documentation for important caveats; in
  particular, yielding within a nursery or cancel scope remains
  unsupported. (`#265 <https://github.com/python-trio/trio/issues/265>`__)


Features
~~~~~~~~

- `trio.open_tcp_stream` has a new ``local_address=`` keyword argument
  that can be used on machines with multiple IP addresses to control
  which IP is used for the outgoing connection. (`#275 <https://github.com/python-trio/trio/issues/275>`__)
- If you pass a raw IP address into ``sendto``, it no longer spends any
  time trying to resolve the hostname. If you're using UDP, this should
  substantially reduce your per-packet overhead. (`#1595 <https://github.com/python-trio/trio/issues/1595>`__)
- `trio.lowlevel.checkpoint` is now much faster. (`#1613 <https://github.com/python-trio/trio/issues/1613>`__)
- We switched to a new, lower-overhead data structure to track upcoming
  timeouts, which should make your programs faster. (`#1629 <https://github.com/python-trio/trio/issues/1629>`__)


Bugfixes
~~~~~~~~

- On macOS and BSDs, explicitly close our wakeup socketpair when we're
  done with it. (`#1621 <https://github.com/python-trio/trio/issues/1621>`__)
- Trio can now be imported when `sys.excepthook` is a `functools.partial` instance, which might occur in a
  ``pytest-qt`` test function. (`#1630 <https://github.com/python-trio/trio/issues/1630>`__)
- The thread cache didn't release its reference to the previous job. (`#1638 <https://github.com/python-trio/trio/issues/1638>`__)
- On Windows, Trio now works around the buggy behavior of certain
  Layered Service Providers (system components that can intercept
  network activity) that are built on top of a commercially available
  library called Komodia Redirector. This benefits users of products
  such as Astrill VPN and Qustodio parental controls. Previously, Trio
  would crash on startup when run on a system where such a product was
  installed. (`#1659 <https://github.com/python-trio/trio/issues/1659>`__)


Deprecations and removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- Remove ``wait_socket_*``, ``notify_socket_closing``, ``notify_fd_closing``, ``run_sync_in_worker_thread`` and ``current_default_worker_thread_limiter``. They were deprecated in 0.12.0. (`#1596 <https://github.com/python-trio/trio/issues/1596>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- When using :ref:`instruments <instrumentation>`, you now only "pay for what you use":
  if there are no instruments installed that override a particular hook such as
  :meth:`~trio.abc.Instrument.before_task_step`, then Trio doesn't waste any effort
  on checking its instruments when the event corresponding to that hook occurs.
  Previously, installing any instrument would incur all the instrumentation overhead,
  even for hooks no one was interested in. (`#1340 <https://github.com/python-trio/trio/issues/1340>`__)


Trio 0.16.0 (2020-06-10)
------------------------

Headline features
~~~~~~~~~~~~~~~~~

- If you want to use Trio, but are stuck with some other event loop like
  Qt or PyGame, then good news: now you can have both. For details, see:
  :ref:`guest-mode`. (`#399 <https://github.com/python-trio/trio/issues/399>`__)


Features
~~~~~~~~

- To speed up `trio.to_thread.run_sync`, Trio now caches and reuses
  worker threads.

  And in case you have some exotic use case where you need to spawn
  threads manually, but want to take advantage of Trio's cache, you can
  do that using the new `trio.lowlevel.start_thread_soon`. (`#6 <https://github.com/python-trio/trio/issues/6>`__)
- Tasks spawned with `nursery.start() <trio.Nursery.start>` aren't treated as
  direct children of their nursery until they call ``task_status.started()``.
  This is visible through the task tree introspection attributes such as
  `Task.parent_nursery <trio.lowlevel.Task.parent_nursery>`. Sometimes, though,
  you want to know where the task is going to wind up, even if it hasn't finished
  initializing yet. To support this, we added a new attribute
  `Task.eventual_parent_nursery <trio.lowlevel.Task.eventual_parent_nursery>`.
  For a task spawned with :meth:`~trio.Nursery.start` that hasn't yet called
  ``started()``, this is the nursery that the task was nominally started in,
  where it will be running once it finishes starting up. In all other cases,
  it is ``None``. (`#1558 <https://github.com/python-trio/trio/issues/1558>`__)


Bugfixes
~~~~~~~~

- Added a helpful error message if an async function is passed to `trio.to_thread.run_sync`. (`#1573 <https://github.com/python-trio/trio/issues/1573>`__)


Deprecations and removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- Remove ``BlockingTrioPortal``: it was deprecated in 0.12.0. (`#1574 <https://github.com/python-trio/trio/issues/1574>`__)
- The ``tiebreaker`` argument to `trio.testing.wait_all_tasks_blocked`
  has been deprecated. This is a highly obscure feature that was
  probably never used by anyone except `trio.testing.MockClock`, and
  `~trio.testing.MockClock` doesn't need it anymore. (`#1587 <https://github.com/python-trio/trio/issues/1587>`__)
- Remove the deprecated ``trio.ssl`` and ``trio.subprocess`` modules. (`#1594 <https://github.com/python-trio/trio/issues/1594>`__)


Miscellaneous internal changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- We refactored `trio.testing.MockClock` so that it no longer needs to
  run an internal task to manage autojumping. This should be mostly
  invisible to users, but there is one semantic change: the interaction
  between `trio.testing.wait_all_tasks_blocked` and the autojump clock
  was fixed. Now, the autojump will always wait until after all
  `~trio.testing.wait_all_tasks_blocked` calls have finished before
  firing, instead of it depending on which threshold values you passed. (`#1587 <https://github.com/python-trio/trio/issues/1587>`__)


Trio 0.15.1 (2020-05-22)
------------------------

Bugfixes
~~~~~~~~

- Fix documentation build. (This must be a new release tag to get readthedocs
  "stable" to include the changes from 0.15.0.)

- Added a helpful error message if an async function is passed to `trio.from_thread.run_sync` or a sync function to `trio.from_thread.run`. (`#1244 <https://github.com/python-trio/trio/issues/1244>`__)


Trio 0.15.0 (2020-05-19)
------------------------

Features
~~~~~~~~

- Previously, when `trio.run_process` was cancelled, it always killed
  the subprocess immediately. Now, on Unix, it first gives the process a
  chance to clean up by sending ``SIGTERM``, and only escalates to
  ``SIGKILL`` if the process is still running after 5 seconds. But if
  you prefer the old behavior, or want to adjust the timeout, then don't
  worry: you can now pass a custom ``deliver_cancel=`` argument to
  define your own process killing policy. (`#1104 <https://github.com/python-trio/trio/issues/1104>`__)
- It turns out that creating a subprocess can block the parent process
  for a surprisingly long time. So ``trio.open_process`` now uses a worker
  thread to avoid blocking the event loop. (`#1109 <https://github.com/python-trio/trio/issues/1109>`__)
- We've added FreeBSD to the list of platforms we support and test on. (`#1118 <https://github.com/python-trio/trio/issues/1118>`__)
- On Linux kernels v5.3 or newer, `trio.Process.wait` now uses `the
  pidfd API <https://lwn.net/Articles/794707/>`__ to track child
  processes. This shouldn't have any user-visible change, but it makes
  working with subprocesses faster and use less memory. (`#1241 <https://github.com/python-trio/trio/issues/1241>`__)
- The `trio.Process.returncode` attribute is now automatically updated
  as needed, instead of only when you call `~trio.Process.poll` or
  `~trio.Process.wait`. Also, ``repr(process_object)`` now always
  contains up-to-date information about the process status. (`#1315 <https://github.com/python-trio/trio/issues/1315>`__)


Bugfixes
~~~~~~~~

- On Ubuntu systems, the system Python includes a custom
  unhandled-exception hook to perform `crash reporting
  <https://wiki.ubuntu.com/Apport>`__. Unfortunately, Trio wants to use
  the same hook to print nice ``MultiError`` tracebacks, causing a
  conflict. Previously, Trio would detect the conflict, print a warning,
  and you just wouldn't get nice ``MultiError`` tracebacks. Now, Trio has
  gotten clever enough to integrate its hook with Ubuntu's, so the two
  systems should Just Work together. (`#1065 <https://github.com/python-trio/trio/issues/1065>`__)
- Fixed an over-strict test that caused failures on Alpine Linux.
  Started testing against Alpine in CI. (`#1499 <https://github.com/python-trio/trio/issues/1499>`__)
- Calling `open_signal_receiver` with no arguments used to succeed without listening for any signals. This was confusing, so now it raises TypeError instead. (`#1526 <https://github.com/python-trio/trio/issues/1526>`__)


Deprecations and Removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- Remove support for Python 3.5. (`#75 <https://github.com/python-trio/trio/issues/75>`__)
- It turns out that everyone got confused by the name ``trio.hazmat``.
  So that name has been deprecated, and the new name is
  :mod:`trio.lowlevel`. (`#476 <https://github.com/python-trio/trio/issues/476>`__)
- Most of the public classes that Trio exports – like `trio.Lock`,
  `trio.SocketStream`, and so on – weren't designed with subclassing in
  mind. And we've noticed that some users were trying to subclass them
  anyway, and ending up with fragile code that we're likely to
  accidentally break in the future, or else be stuck unable to make
  changes for fear of breaking subclasses.

  There are also some classes that were explicitly designed to be
  subclassed, like the ones in ``trio.abc``. Subclassing these is still
  supported. However, for all other classes, attempts to subclass will
  now raise a deprecation warning, and in the future will raise an
  error.

  If this causes problems for you, feel free to drop by our `chat room
  <https://gitter.im/python-trio/general>`__ or file a bug, to discuss
  alternatives or make a case for why some particular class should be
  designed to support subclassing. (`#1044 <https://github.com/python-trio/trio/issues/1044>`__)
- If you want to create a `trio.Process` object, you now have to call
  ``trio.open_process``; calling ``trio.Process()`` directly was
  deprecated in v0.12.0 and has now been removed. (`#1109 <https://github.com/python-trio/trio/issues/1109>`__)
- Remove ``clear`` method on `trio.Event`: it was deprecated in 0.12.0. (`#1498 <https://github.com/python-trio/trio/issues/1498>`__)


Trio 0.14.0 (2020-04-27)
------------------------

Features
~~~~~~~~

- If you're using Trio's low-level interfaces like
  `trio.hazmat.wait_readable <trio.lowlevel.wait_readable>` or similar, and then you close a socket or
  file descriptor, you're supposed to call `trio.hazmat.notify_closing
  <trio.lowlevel.notify_closing>`
  first so Trio can clean up properly. But what if you forget? In the
  past, Trio would tend to either deadlock or explode spectacularly.
  Now, it's much more robust to this situation, and should generally
  survive. (But note that "survive" is not the same as "give you the
  results you were expecting", so you should still call
  `~trio.lowlevel.notify_closing` when appropriate. This is about harm
  reduction and making it easier to debug this kind of mistake, not
  something you should rely on.)

  If you're using higher-level interfaces outside of the `trio.hazmat <trio.lowlevel>`
  module, then you don't need to worry about any of this; those
  interfaces already take care of calling `~trio.lowlevel.notify_closing`
  for you. (`#1272 <https://github.com/python-trio/trio/issues/1272>`__)


Bugfixes
~~~~~~~~

- A bug related to the following methods has been introduced in version 0.12.0:

  - `trio.Path.iterdir`
  - `trio.Path.glob`
  - `trio.Path.rglob`

  The iteration of the blocking generators produced by pathlib was performed in
  the trio thread. With this fix, the previous behavior is restored: the blocking
  generators are converted into lists in a thread dedicated to blocking IO calls. (`#1308 <https://github.com/python-trio/trio/issues/1308>`__)


Deprecations and Removals
~~~~~~~~~~~~~~~~~~~~~~~~~

- Deprecate Python 3.5 (`#1408 <https://github.com/python-trio/trio/pull/1408>`__)
- Remove ``trio.open_cancel_scope`` which was deprecated in 0.11.0. (`#1458 <https://github.com/python-trio/trio/issues/1458>`__)


Trio 0.13.0 (2019-11-02)
------------------------

Features
~~~~~~~~

- On Windows, the `IOCP subsystem
  <https://docs.micros
Download .txt
gitextract_o0e72cdj/

├── .builds/
│   ├── alpine.yml
│   ├── fedora.yml
│   └── freebsd.yml
├── .codecov.yml
├── .git-blame-ignore-revs
├── .gitattributes
├── .github/
│   └── workflows/
│       ├── autodeps.yml
│       ├── check-newsfragment.yml
│       ├── ci.yml
│       └── release.yml
├── .gitignore
├── .pre-commit-config.yaml
├── .readthedocs.yml
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── LICENSE.APACHE2
├── LICENSE.MIT
├── MANIFEST.in
├── README.rst
├── ci.sh
├── docs/
│   ├── Makefile
│   ├── make.bat
│   ├── notes.txt
│   └── source/
│       ├── _static/
│       │   ├── .gitkeep
│       │   └── styles.css
│       ├── _templates/
│       │   ├── .gitkeep
│       │   ├── genindex.html
│       │   └── layout.html
│       ├── awesome-trio-libraries.rst
│       ├── code-of-conduct.rst
│       ├── conf.py
│       ├── contributing.rst
│       ├── design.rst
│       ├── glossary.rst
│       ├── history.rst
│       ├── index.rst
│       ├── local_customization.py
│       ├── reference-core/
│       │   ├── channels-backpressure.py
│       │   ├── channels-mpmc-broken.py
│       │   ├── channels-mpmc-fixed.py
│       │   ├── channels-shutdown.py
│       │   ├── channels-simple.py
│       │   ├── contextvar-example.py
│       │   ├── from-thread-example.py
│       │   └── thread-contextvars-example.py
│       ├── reference-core.rst
│       ├── reference-io.rst
│       ├── reference-lowlevel.rst
│       ├── reference-testing/
│       │   ├── across-realtime.out
│       │   └── across-realtime.py
│       ├── reference-testing.rst
│       ├── releasing.rst
│       ├── tutorial/
│       │   ├── echo-client.py
│       │   ├── echo-server.py
│       │   ├── tasks-intro.py
│       │   └── tasks-with-trace.py
│       ├── tutorial.rst
│       └── typevars.py
├── docs-requirements.in
├── docs-requirements.txt
├── newsfragments/
│   ├── .gitkeep
│   ├── 3261.bugfix.rst
│   └── README.rst
├── pyproject.toml
├── src/
│   └── trio/
│       ├── __init__.py
│       ├── __main__.py
│       ├── _abc.py
│       ├── _channel.py
│       ├── _core/
│       │   ├── __init__.py
│       │   ├── _asyncgens.py
│       │   ├── _concat_tb.py
│       │   ├── _entry_queue.py
│       │   ├── _exceptions.py
│       │   ├── _generated_instrumentation.py
│       │   ├── _generated_io_epoll.py
│       │   ├── _generated_io_kqueue.py
│       │   ├── _generated_io_windows.py
│       │   ├── _generated_run.py
│       │   ├── _generated_windows_ffi.py
│       │   ├── _instrumentation.py
│       │   ├── _io_common.py
│       │   ├── _io_epoll.py
│       │   ├── _io_kqueue.py
│       │   ├── _io_windows.py
│       │   ├── _ki.py
│       │   ├── _local.py
│       │   ├── _mock_clock.py
│       │   ├── _parking_lot.py
│       │   ├── _run.py
│       │   ├── _run_context.py
│       │   ├── _tests/
│       │   │   ├── __init__.py
│       │   │   ├── test_asyncgen.py
│       │   │   ├── test_cancelled.py
│       │   │   ├── test_exceptiongroup_gc.py
│       │   │   ├── test_guest_mode.py
│       │   │   ├── test_instrumentation.py
│       │   │   ├── test_io.py
│       │   │   ├── test_ki.py
│       │   │   ├── test_local.py
│       │   │   ├── test_mock_clock.py
│       │   │   ├── test_parking_lot.py
│       │   │   ├── test_run.py
│       │   │   ├── test_thread_cache.py
│       │   │   ├── test_tutil.py
│       │   │   ├── test_unbounded_queue.py
│       │   │   ├── test_windows.py
│       │   │   ├── tutil.py
│       │   │   └── type_tests/
│       │   │       ├── nursery_start.py
│       │   │       └── run.py
│       │   ├── _thread_cache.py
│       │   ├── _traps.py
│       │   ├── _unbounded_queue.py
│       │   ├── _wakeup_socketpair.py
│       │   └── _windows_cffi.py
│       ├── _deprecate.py
│       ├── _dtls.py
│       ├── _file_io.py
│       ├── _highlevel_generic.py
│       ├── _highlevel_open_tcp_listeners.py
│       ├── _highlevel_open_tcp_stream.py
│       ├── _highlevel_open_unix_stream.py
│       ├── _highlevel_serve_listeners.py
│       ├── _highlevel_socket.py
│       ├── _highlevel_ssl_helpers.py
│       ├── _path.py
│       ├── _repl.py
│       ├── _signals.py
│       ├── _socket.py
│       ├── _ssl.py
│       ├── _subprocess.py
│       ├── _subprocess_platform/
│       │   ├── __init__.py
│       │   ├── kqueue.py
│       │   ├── waitid.py
│       │   └── windows.py
│       ├── _sync.py
│       ├── _tests/
│       │   ├── __init__.py
│       │   ├── _check_type_completeness.json
│       │   ├── astrill-codesigning-cert.cer
│       │   ├── check_type_completeness.py
│       │   ├── module_with_deprecations.py
│       │   ├── pytest_plugin.py
│       │   ├── test_abc.py
│       │   ├── test_channel.py
│       │   ├── test_contextvars.py
│       │   ├── test_deprecate.py
│       │   ├── test_deprecate_strict_exception_groups_false.py
│       │   ├── test_dtls.py
│       │   ├── test_exports.py
│       │   ├── test_fakenet.py
│       │   ├── test_file_io.py
│       │   ├── test_highlevel_generic.py
│       │   ├── test_highlevel_open_tcp_listeners.py
│       │   ├── test_highlevel_open_tcp_stream.py
│       │   ├── test_highlevel_open_unix_stream.py
│       │   ├── test_highlevel_serve_listeners.py
│       │   ├── test_highlevel_socket.py
│       │   ├── test_highlevel_ssl_helpers.py
│       │   ├── test_path.py
│       │   ├── test_repl.py
│       │   ├── test_scheduler_determinism.py
│       │   ├── test_signals.py
│       │   ├── test_socket.py
│       │   ├── test_ssl.py
│       │   ├── test_subprocess.py
│       │   ├── test_sync.py
│       │   ├── test_testing.py
│       │   ├── test_testing_raisesgroup.py
│       │   ├── test_threads.py
│       │   ├── test_timeouts.py
│       │   ├── test_tracing.py
│       │   ├── test_trio.py
│       │   ├── test_unix_pipes.py
│       │   ├── test_util.py
│       │   ├── test_wait_for_object.py
│       │   ├── test_windows_pipes.py
│       │   ├── tools/
│       │   │   ├── __init__.py
│       │   │   ├── test_gen_exports.py
│       │   │   ├── test_mypy_annotate.py
│       │   │   └── test_sync_requirements.py
│       │   └── type_tests/
│       │       ├── check_wraps.py
│       │       ├── open_memory_channel.py
│       │       ├── path.py
│       │       ├── subprocesses.py
│       │       └── task_status.py
│       ├── _threads.py
│       ├── _timeouts.py
│       ├── _tools/
│       │   ├── __init__.py
│       │   ├── gen_exports.py
│       │   ├── mypy_annotate.py
│       │   ├── sync_requirements.py
│       │   └── windows_ffi_build.py
│       ├── _unix_pipes.py
│       ├── _util.py
│       ├── _version.py
│       ├── _wait_for_object.py
│       ├── _windows_pipes.py
│       ├── abc.py
│       ├── from_thread.py
│       ├── lowlevel.py
│       ├── py.typed
│       ├── socket.py
│       ├── testing/
│       │   ├── __init__.py
│       │   ├── _check_streams.py
│       │   ├── _checkpoints.py
│       │   ├── _fake_net.py
│       │   ├── _memory_streams.py
│       │   ├── _network.py
│       │   ├── _raises_group.py
│       │   ├── _sequencer.py
│       │   └── _trio_test.py
│       └── to_thread.py
├── test-requirements.in
├── test-requirements.txt
├── tests/
│   ├── _trio_check_attrs_aliases.py
│   └── cython/
│       ├── run_test_cython.py
│       └── test_cython.pyx
├── tox.ini
└── zizmor.yml
Download .txt
SYMBOL INDEX (2206 symbols across 143 files)

FILE: docs/source/conf.py
  function on_read_source (line 93) | def on_read_source(app: Sphinx, docname: str, content: list[str]) -> None:
  function autodoc_process_signature (line 147) | def autodoc_process_signature(
  function autodoc_process_docstring (line 189) | def autodoc_process_docstring(
  function setup (line 210) | def setup(app: Sphinx) -> None:
  function add_intersphinx (line 261) | def add_intersphinx(app: Sphinx) -> None:

FILE: docs/source/local_customization.py
  class Interface (line 28) | class Interface(PyClasslike):
    method handle_signature (line 29) | def handle_signature(self, sig: str, signode: desc_signature) -> tuple...
    method get_index_text (line 33) | def get_index_text(self, modname: str, name_cls: tuple[str, str]) -> str:
  function setup (line 37) | def setup(app: Sphinx) -> None:

FILE: docs/source/reference-core/channels-backpressure.py
  function producer (line 8) | async def producer(send_channel):
  function consumer (line 19) | async def consumer(receive_channel):
  function main (line 27) | async def main():

FILE: docs/source/reference-core/channels-mpmc-broken.py
  function main (line 7) | async def main():
  function producer (line 18) | async def producer(name, send_channel):
  function consumer (line 26) | async def consumer(name, receive_channel):

FILE: docs/source/reference-core/channels-mpmc-fixed.py
  function main (line 5) | async def main():
  function producer (line 17) | async def producer(name, send_channel):
  function consumer (line 25) | async def consumer(name, receive_channel):

FILE: docs/source/reference-core/channels-shutdown.py
  function main (line 4) | async def main():
  function producer (line 11) | async def producer(send_channel):
  function consumer (line 17) | async def consumer(receive_channel):

FILE: docs/source/reference-core/channels-simple.py
  function main (line 4) | async def main():
  function producer (line 14) | async def producer(send_channel):
  function consumer (line 21) | async def consumer(receive_channel):

FILE: docs/source/reference-core/contextvar-example.py
  function log (line 9) | def log(msg):
  function handle_request (line 18) | async def handle_request(tag):
  function concurrent_helper (line 31) | async def concurrent_helper(job):
  function main (line 39) | async def main():

FILE: docs/source/reference-core/from-thread-example.py
  function thread_fn (line 4) | def thread_fn(receive_from_trio, send_to_trio):
  function main (line 18) | async def main():

FILE: docs/source/reference-core/thread-contextvars-example.py
  function work_in_thread (line 11) | def work_in_thread(msg):
  function handle_request (line 24) | async def handle_request(current_user_id):
  function main (line 41) | async def main():

FILE: docs/source/reference-testing/across-realtime.py
  function task1 (line 10) | async def task1():
  function task2 (line 27) | async def task2():
  function main (line 43) | async def main():
  function run_example (line 49) | def run_example(clock):

FILE: docs/source/tutorial/echo-client.py
  function sender (line 13) | async def sender(client_stream):
  function receiver (line 22) | async def receiver(client_stream):
  function parent (line 30) | async def parent():

FILE: docs/source/tutorial/echo-server.py
  function echo_server (line 15) | async def echo_server(server_stream):
  function main (line 35) | async def main():

FILE: docs/source/tutorial/tasks-intro.py
  function child1 (line 6) | async def child1():
  function child2 (line 12) | async def child2():
  function parent (line 18) | async def parent():

FILE: docs/source/tutorial/tasks-with-trace.py
  function child1 (line 6) | async def child1():
  function child2 (line 12) | async def child2():
  function parent (line 18) | async def parent():
  class Tracer (line 32) | class Tracer(trio.abc.Instrument):
    method before_run (line 33) | def before_run(self):
    method _print_with_task (line 36) | def _print_with_task(self, msg, task):
    method task_spawned (line 41) | def task_spawned(self, task):
    method task_scheduled (line 44) | def task_scheduled(self, task):
    method before_task_step (line 47) | def before_task_step(self, task):
    method after_task_step (line 50) | def after_task_step(self, task):
    method task_exited (line 53) | def task_exited(self, task):
    method before_io_wait (line 56) | def before_io_wait(self, timeout):
    method after_io_wait (line 63) | def after_io_wait(self, timeout):
    method after_run (line 67) | def after_run(self):

FILE: docs/source/typevars.py
  function identify_typevars (line 21) | def identify_typevars(trio_folder: Path) -> None:
  function lookup_reference (line 49) | def lookup_reference(
  function setup (line 104) | def setup(app: Sphinx) -> None:

FILE: src/trio/_abc.py
  class Clock (line 19) | class Clock(ABC):
    method start_clock (line 25) | def start_clock(self) -> None:
    method current_time (line 33) | def current_time(self) -> float:
    method deadline_to_sleep_time (line 45) | def deadline_to_sleep_time(self, deadline: float) -> float:
  class Instrument (line 69) | class Instrument(ABC):  # noqa: B024  # conceptually is ABC
    method before_run (line 79) | def before_run(self) -> None:
    method after_run (line 83) | def after_run(self) -> None:
    method task_spawned (line 87) | def task_spawned(self, task: Task) -> None:
    method task_scheduled (line 96) | def task_scheduled(self, task: Task) -> None:
    method before_task_step (line 108) | def before_task_step(self, task: Task) -> None:
    method after_task_step (line 117) | def after_task_step(self, task: Task) -> None:
    method task_exited (line 126) | def task_exited(self, task: Task) -> None:
    method before_io_wait (line 135) | def before_io_wait(self, timeout: float) -> None:
    method after_io_wait (line 144) | def after_io_wait(self, timeout: float) -> None:
  class HostnameResolver (line 156) | class HostnameResolver(ABC):
    method getaddrinfo (line 167) | async def getaddrinfo(
    method getnameinfo (line 198) | async def getnameinfo(
  class SocketFactory (line 210) | class SocketFactory(ABC):
    method socket (line 221) | def socket(
  class AsyncResource (line 243) | class AsyncResource(ABC):
    method aclose (line 272) | async def aclose(self) -> None:
    method __aenter__ (line 300) | async def __aenter__(self) -> Self:
    method __aexit__ (line 303) | async def __aexit__(
  class SendStream (line 312) | class SendStream(AsyncResource):
    method send_all (line 331) | async def send_all(self, data: bytes | bytearray | memoryview) -> None:
    method wait_send_all_might_not_block (line 357) | async def wait_send_all_might_not_block(self) -> None:
  class ReceiveStream (line 413) | class ReceiveStream(AsyncResource):
    method receive_some (line 437) | async def receive_some(self, max_bytes: int | None = None) -> bytes | ...
    method __aiter__ (line 465) | def __aiter__(self) -> Self:
    method __anext__ (line 468) | async def __anext__(self) -> bytes | bytearray:
  class Stream (line 475) | class Stream(SendStream, ReceiveStream):
  class HalfCloseableStream (line 489) | class HalfCloseableStream(Stream):
    method send_eof (line 498) | async def send_eof(self) -> None:
  class Listener (line 565) | class Listener(AsyncResource, Generic[T_resource]):
    method accept (line 577) | async def accept(self) -> T_resource:
  class SendChannel (line 604) | class SendChannel(AsyncResource, Generic[SendType]):
    method send (line 619) | async def send(self, value: SendType) -> None:
  class ReceiveChannel (line 640) | class ReceiveChannel(AsyncResource, Generic[ReceiveType]):
    method receive (line 664) | async def receive(self) -> ReceiveType:
    method __aiter__ (line 684) | def __aiter__(self) -> Self:
    method __anext__ (line 687) | async def __anext__(self) -> ReceiveType:
  class Channel (line 702) | class Channel(SendChannel[T], ReceiveChannel[T]):

FILE: src/trio/_channel.py
  class open_memory_channel (line 49) | class open_memory_channel(tuple["MemorySendChannel[T]", "MemoryReceiveCh...
    method __new__ (line 101) | def __new__(  # type: ignore[misc]  # "must return a subtype"
    method __init__ (line 115) | def __init__(self, max_buffer_size: int | float) -> None:  # noqa: PYI041
  class MemoryChannelStatistics (line 120) | class MemoryChannelStatistics:
  class MemoryChannelState (line 130) | class MemoryChannelState(Generic[T]):
    method statistics (line 141) | def statistics(self) -> MemoryChannelStatistics:
  class MemorySendChannel (line 154) | class MemorySendChannel(SendChannel[SendType], metaclass=NoPublicConstru...
    method __attrs_post_init__ (line 162) | def __attrs_post_init__(self) -> None:
    method __repr__ (line 165) | def __repr__(self) -> str:
    method statistics (line 168) | def statistics(self) -> MemoryChannelStatistics:
    method send_nowait (line 175) | def send_nowait(self, value: SendType) -> None:
    method send (line 195) | async def send(self, value: SendType) -> None:
    method clone (line 224) | def clone(self) -> MemorySendChannel[SendType]:
    method __enter__ (line 252) | def __enter__(self) -> Self:
    method __exit__ (line 255) | def __exit__(
    method close (line 264) | def close(self) -> None:
    method aclose (line 292) | async def aclose(self) -> None:
  class MemoryReceiveChannel (line 302) | class MemoryReceiveChannel(ReceiveChannel[ReceiveType], metaclass=NoPubl...
    method __attrs_post_init__ (line 307) | def __attrs_post_init__(self) -> None:
    method statistics (line 310) | def statistics(self) -> MemoryChannelStatistics:
    method __repr__ (line 315) | def __repr__(self) -> str:
    method receive_nowait (line 321) | def receive_nowait(self) -> ReceiveType:
    method receive (line 341) | async def receive(self) -> ReceiveType:
    method clone (line 373) | def clone(self) -> MemoryReceiveChannel[ReceiveType]:
    method __enter__ (line 404) | def __enter__(self) -> Self:
    method __exit__ (line 407) | def __exit__(
    method close (line 416) | def close(self) -> None:
    method aclose (line 445) | async def aclose(self) -> None:
  class RecvChanWrapper (line 453) | class RecvChanWrapper(ReceiveChannel[T]):
    method __init__ (line 454) | def __init__(
    method receive (line 460) | async def receive(self) -> T:
    method aclose (line 464) | async def aclose(self) -> None:
    method __enter__ (line 467) | def __enter__(self) -> Self:
    method __exit__ (line 470) | def __exit__(
  function as_safe_channel (line 479) | def as_safe_channel(

FILE: src/trio/_core/_asyncgens.py
  function _call_without_ki_protection (line 36) | def _call_without_ki_protection(
  class AsyncGenerators (line 46) | class AsyncGenerators:
    method install_hooks (line 68) | def install_hooks(self, runner: _run.Runner) -> None:
    method finalize_remaining (line 160) | async def finalize_remaining(self, runner: _run.Runner) -> None:
    method close (line 220) | def close(self) -> None:
    method _finalize_one (line 223) | async def _finalize_one(

FILE: src/trio/_core/_concat_tb.py
  function concat_tb (line 9) | def concat_tb(

FILE: src/trio/_core/_entry_queue.py
  class EntryQueue (line 24) | class EntryQueue:
    method task (line 47) | async def task(self) -> None:
    method close (line 124) | def close(self) -> None:
    method size (line 127) | def size(self) -> int:
    method run_sync_soon (line 130) | def run_sync_soon(
  class TrioToken (line 153) | class TrioToken(metaclass=NoPublicConstructor):
    method run_sync_soon (line 174) | def run_sync_soon(

FILE: src/trio/_core/_exceptions.py
  class TrioInternalError (line 25) | class TrioInternalError(Exception):
  class RunFinishedError (line 39) | class RunFinishedError(RuntimeError):
  class WouldBlock (line 46) | class WouldBlock(Exception):
  class Cancelled (line 52) | class Cancelled(BaseException, metaclass=NoPublicConstructor):
    method __str__ (line 90) | def __str__(self) -> str:
    method __reduce__ (line 97) | def __reduce__(self) -> tuple[Callable[[], Cancelled], tuple[()]]:
    method _create (line 114) | def _create(
  class BusyResourceError (line 123) | class BusyResourceError(Exception):
  class ClosedResourceError (line 134) | class ClosedResourceError(Exception):
  class BrokenResourceError (line 147) | class BrokenResourceError(Exception):
  class EndOfChannel (line 163) | class EndOfChannel(Exception):

FILE: src/trio/_core/_generated_instrumentation.py
  function add_instrument (line 18) | def add_instrument(instrument: Instrument) -> None:
  function remove_instrument (line 34) | def remove_instrument(instrument: Instrument) -> None:

FILE: src/trio/_core/_generated_io_epoll.py
  function wait_readable (line 22) | async def wait_readable(fd: int | _HasFileNo) -> None:
  function wait_writable (line 51) | async def wait_writable(fd: int | _HasFileNo) -> None:
  function notify_closing (line 70) | def notify_closing(fd: int | _HasFileNo) -> None:

FILE: src/trio/_core/_generated_io_kqueue.py
  function current_kqueue (line 35) | def current_kqueue() -> select.kqueue:
  function monitor_kevent (line 47) | def monitor_kevent(
  function wait_kevent (line 61) | async def wait_kevent(
  function wait_readable (line 77) | async def wait_readable(fd: int | _HasFileNo) -> None:
  function wait_writable (line 106) | async def wait_writable(fd: int | _HasFileNo) -> None:
  function notify_closing (line 125) | def notify_closing(fd: int | _HasFileNo) -> None:

FILE: src/trio/_core/_generated_io_windows.py
  function wait_readable (line 38) | async def wait_readable(sock: _HasFileNo | int) -> None:
  function wait_writable (line 67) | async def wait_writable(sock: _HasFileNo | int) -> None:
  function notify_closing (line 86) | def notify_closing(handle: Handle | int | _HasFileNo) -> None:
  function register_with_iocp (line 118) | def register_with_iocp(handle: int | CData) -> None:
  function wait_overlapped (line 131) | async def wait_overlapped(handle_: int | CData, lpOverlapped: CData | in...
  function write_overlapped (line 146) | async def write_overlapped(
  function readinto_overlapped (line 163) | async def readinto_overlapped(
  function current_iocp (line 180) | def current_iocp() -> int:
  function monitor_completion_key (line 193) | def monitor_completion_key() -> (

FILE: src/trio/_core/_generated_run.py
  function current_statistics (line 36) | def current_statistics() -> RunStatistics:
  function current_time (line 66) | def current_time() -> float:
  function current_clock (line 83) | def current_clock() -> Clock:
  function current_root_task (line 92) | def current_root_task() -> Task | None:
  function reschedule (line 105) | def reschedule(task: Task, next_send: outcome.Outcome[object] = _NO_SEND...
  function spawn_system_task (line 130) | def spawn_system_task(
  function current_trio_token (line 196) | def current_trio_token() -> TrioToken:
  function wait_all_tasks_blocked (line 208) | async def wait_all_tasks_blocked(cushion: float = 0.0) -> None:

FILE: src/trio/_core/_instrumentation.py
  function _public (line 21) | def _public(fn: T) -> T:
  class Instruments (line 25) | class Instruments(UserDict[str, dict[Instrument, None]]):
    method __init__ (line 37) | def __init__(self, incoming: Sequence[Instrument]) -> None:
    method add_instrument (line 43) | def add_instrument(self, instrument: Instrument) -> None:
    method remove_instrument (line 73) | def remove_instrument(self, instrument: Instrument) -> None:
    method call (line 94) | def call(

FILE: src/trio/_core/_io_common.py
  function wake_all (line 16) | def wake_all(waiters: EpollWaiters | AFDWaiters, exc: BaseException) -> ...

FILE: src/trio/_core/_io_epoll.py
  class EpollWaiters (line 22) | class EpollWaiters:
  class _EpollStatistics (line 35) | class _EpollStatistics:
  class EpollIOManager (line 200) | class EpollIOManager:
    method __attrs_post_init__ (line 211) | def __attrs_post_init__(self) -> None:
    method statistics (line 215) | def statistics(self) -> _EpollStatistics:
    method close (line 228) | def close(self) -> None:
    method force_wakeup (line 232) | def force_wakeup(self) -> None:
    method get_events (line 238) | def get_events(self, timeout: float) -> EventResult:
    method process_events (line 245) | def process_events(self, events: EventResult) -> None:
    method _update_registrations (line 264) | def _update_registrations(self, fd: int) -> None:
    method _epoll_wait (line 293) | async def _epoll_wait(self, fd: int | _HasFileNo, attr_name: str) -> N...
    method wait_readable (line 312) | async def wait_readable(self, fd: int | _HasFileNo) -> None:
    method wait_writable (line 337) | async def wait_writable(self, fd: int | _HasFileNo) -> None:
    method notify_closing (line 352) | def notify_closing(self, fd: int | _HasFileNo) -> None:

FILE: src/trio/_core/_io_kqueue.py
  class _KqueueStatistics (line 28) | class _KqueueStatistics:
  class KqueueIOManager (line 35) | class KqueueIOManager:
    method __attrs_post_init__ (line 44) | def __attrs_post_init__(self) -> None:
    method statistics (line 53) | def statistics(self) -> _KqueueStatistics:
    method close (line 63) | def close(self) -> None:
    method force_wakeup (line 67) | def force_wakeup(self) -> None:
    method get_events (line 70) | def get_events(self, timeout: float) -> EventResult:
    method process_events (line 87) | def process_events(self, events: EventResult) -> None:
    method current_kqueue (line 113) | def current_kqueue(self) -> select.kqueue:
    method monitor_kevent (line 122) | def monitor_kevent(
    method wait_kevent (line 144) | async def wait_kevent(
    method _wait_common (line 170) | async def _wait_common(
    method wait_readable (line 206) | async def wait_readable(self, fd: int | _HasFileNo) -> None:
    method wait_writable (line 231) | async def wait_writable(self, fd: int | _HasFileNo) -> None:
    method notify_closing (line 246) | def notify_closing(self, fd: int | _HasFileNo) -> None:

FILE: src/trio/_core/_io_windows.py
  class CKeys (line 191) | class CKeys(enum.IntEnum):
  class AFDWaiters (line 242) | class AFDWaiters:
  class _AFDHandle (line 249) | class _AFDHandle(Protocol):
  class _AFDPollInfo (line 256) | class _AFDPollInfo(Protocol):
  class AFDPollOp (line 267) | class AFDPollOp:
  class AFDGroup (line 286) | class AFDGroup:
  class _WindowsStatistics (line 295) | class _WindowsStatistics:
  function _check (line 310) | def _check(success: T) -> T:
  function _get_underlying_socket (line 316) | def _get_underlying_socket(
  function _get_base_socket (line 342) | def _get_base_socket(sock: _HasFileNo | int | Handle) -> Handle:
  function _afd_helper_handle (line 390) | def _afd_helper_handle() -> Handle:
  class CompletionKeyEventInfo (line 423) | class CompletionKeyEventInfo:
  class WindowsIOManager (line 428) | class WindowsIOManager:
    method __init__ (line 429) | def __init__(self) -> None:
    method close (line 493) | def close(self) -> None:
    method __del__ (line 504) | def __del__(self) -> None:
    method statistics (line 507) | def statistics(self) -> _WindowsStatistics:
    method force_wakeup (line 522) | def force_wakeup(self) -> None:
    method get_events (line 533) | def get_events(self, timeout: float) -> EventResult:
    method process_events (line 558) | def process_events(self, received: EventResult) -> None:
    method _register_with_iocp (line 640) | def _register_with_iocp(self, handle_: int | CData, completion_key: in...
    method _refresh_afd (line 659) | def _refresh_afd(self, base_handle: Handle) -> None:
    method _afd_poll (line 736) | async def _afd_poll(self, sock: _HasFileNo | int, mode: str) -> None:
    method wait_readable (line 757) | async def wait_readable(self, sock: _HasFileNo | int) -> None:
    method wait_writable (line 782) | async def wait_writable(self, sock: _HasFileNo | int) -> None:
    method notify_closing (line 797) | def notify_closing(self, handle: Handle | int | _HasFileNo) -> None:
    method register_with_iocp (line 833) | def register_with_iocp(self, handle: int | CData) -> None:
    method wait_overlapped (line 842) | async def wait_overlapped(
    method _perform_overlapped (line 922) | async def _perform_overlapped(
    method write_overlapped (line 945) | async def write_overlapped(
    method readinto_overlapped (line 978) | async def readinto_overlapped(
    method current_iocp (line 1013) | def current_iocp(self) -> int:
    method monitor_completion_key (line 1024) | def monitor_completion_key(self) -> Iterator[tuple[int, UnboundedQueue...

FILE: src/trio/_core/_ki.py
  class _IdRef (line 83) | class _IdRef(weakref.ref[_T]):
    method __new__ (line 87) | def __new__(
    method __eq__ (line 97) | def __eq__(self, other: object) -> bool:
    method __ne__ (line 112) | def __ne__(self, other: object) -> bool:
    method __hash__ (line 115) | def __hash__(self) -> int:
  class WeakKeyIdentityDictionary (line 124) | class WeakKeyIdentityDictionary(Generic[_KT, _VT]):
    method __init__ (line 125) | def __init__(self) -> None:
    method __getitem__ (line 145) | def __getitem__(self, k: _KT) -> _VT:
    method __setitem__ (line 148) | def __setitem__(self, k: _KT, v: _VT) -> None:
  function legacy_isasyncgenfunction (line 162) | def legacy_isasyncgenfunction(
  function ki_protection_enabled (line 170) | def ki_protection_enabled(frame: types.FrameType | None) -> bool:
  function currently_ki_protected (line 195) | def currently_ki_protected() -> bool:
  class _SupportsCode (line 211) | class _SupportsCode(Protocol):
  function enable_ki_protection (line 218) | def enable_ki_protection(f: _T_supports_code, /) -> _T_supports_code:
  function disable_ki_protection (line 229) | def disable_ki_protection(f: _T_supports_code, /) -> _T_supports_code:
  class KIManager (line 241) | class KIManager:
    method install (line 244) | def install(
    method close (line 267) | def close(self) -> None:

FILE: src/trio/_core/_local.py
  class _NoValue (line 15) | class _NoValue: ...
  class RunVarToken (line 20) | class RunVarToken(Generic[T], metaclass=NoPublicConstructor):
    method _empty (line 26) | def _empty(cls, var: RunVar[T]) -> RunVarToken[T]:
  class RunVar (line 32) | class RunVar(Generic[T]):
    method get (line 44) | def get(self, default: T | type[_NoValue] = _NoValue) -> T:
    method set (line 61) | def set(self, value: T) -> RunVarToken[T]:
    method reset (line 78) | def reset(self, token: RunVarToken[T]) -> None:
    method __repr__ (line 103) | def __repr__(self) -> str:

FILE: src/trio/_core/_mock_clock.py
  class MockClock (line 18) | class MockClock(Clock):
    method __init__ (line 66) | def __init__(self, rate: float = 0.0, autojump_threshold: float = inf)...
    method __repr__ (line 81) | def __repr__(self) -> str:
    method rate (line 85) | def rate(self) -> float:
    method rate (line 89) | def rate(self, new_rate: float) -> None:
    method autojump_threshold (line 100) | def autojump_threshold(self) -> float:
    method autojump_threshold (line 104) | def autojump_threshold(self, new_autojump_threshold: float) -> None:
    method _try_resync_autojump_threshold (line 114) | def _try_resync_autojump_threshold(self) -> None:
    method _autojump (line 127) | def _autojump(self) -> None:
    method _real_to_virtual (line 133) | def _real_to_virtual(self, real: float) -> float:
    method start_clock (line 138) | def start_clock(self) -> None:
    method current_time (line 141) | def current_time(self) -> float:
    method deadline_to_sleep_time (line 144) | def deadline_to_sleep_time(self, deadline: float) -> float:
    method jump (line 153) | def jump(self, seconds: float) -> None:

FILE: src/trio/_core/_parking_lot.py
  function add_parking_lot_breaker (line 94) | def add_parking_lot_breaker(task: Task, lot: ParkingLot) -> None:
  function remove_parking_lot_breaker (line 110) | def remove_parking_lot_breaker(task: Task, lot: ParkingLot) -> None:
  class ParkingLotStatistics (line 123) | class ParkingLotStatistics:
  class ParkingLot (line 138) | class ParkingLot:
    method __len__ (line 156) | def __len__(self) -> int:
    method __bool__ (line 160) | def __bool__(self) -> bool:
    method park (line 169) | async def park(self) -> None:
    method _pop_several (line 192) | def _pop_several(self, count: int | float) -> Iterator[Task]:  # noqa:...
    method unpark (line 205) | def unpark(self, *, count: int | float = 1) -> list[Task]:  # noqa: PY...
    method unpark_all (line 221) | def unpark_all(self) -> list[Task]:
    method repark (line 226) | def repark(
    method repark_all (line 270) | def repark_all(self, new_lot: ParkingLot) -> None:
    method break_lot (line 279) | def break_lot(self, task: Task | None = None) -> None:
    method statistics (line 308) | def statistics(self) -> ParkingLotStatistics:

FILE: src/trio/_core/_run.py
  class _NoStatus (line 104) | class _NoStatus(metaclass=NoPublicConstructor):
  function _public (line 110) | def _public(fn: RetT) -> RetT:
  function _hypothesis_plugin_setup (line 125) | def _hypothesis_plugin_setup() -> None:  # pragma: no cover
  function _count_context_run_tb_frames (line 148) | def _count_context_run_tb_frames() -> int:
  class SystemClock (line 193) | class SystemClock(Clock):
    method start_clock (line 199) | def start_clock(self) -> None:
    method current_time (line 205) | def current_time(self) -> float:
    method deadline_to_sleep_time (line 208) | def deadline_to_sleep_time(self, deadline: float) -> float:
  class IdlePrimedTypes (line 212) | class IdlePrimedTypes(enum.Enum):
  function collapse_exception_group (line 222) | def collapse_exception_group(
  class Deadlines (line 255) | class Deadlines:
    method add (line 268) | def add(self, deadline: float, cancel_scope: CancelScope) -> None:
    method remove (line 272) | def remove(self, deadline: float, cancel_scope: CancelScope) -> None:
    method next_deadline (line 275) | def next_deadline(self) -> float:
    method _prune (line 285) | def _prune(self) -> None:
    method expire (line 306) | def expire(self, now: float) -> bool:
  class CancelReason (line 324) | class CancelReason:
  class CancelStatus (line 338) | class CancelStatus:
    method __attrs_post_init__ (line 404) | def __attrs_post_init__(self) -> None:
    method parent (line 412) | def parent(self) -> CancelStatus | None:
    method parent (line 416) | def parent(self, parent: CancelStatus | None) -> None:
    method children (line 425) | def children(self) -> frozenset[CancelStatus]:
    method tasks (line 429) | def tasks(self) -> frozenset[Task]:
    method encloses (line 432) | def encloses(self, other: CancelStatus | None) -> bool:
    method close (line 442) | def close(self) -> None:
    method parent_cancellation_is_visible_to_us (line 471) | def parent_cancellation_is_visible_to_us(self) -> bool:
    method recalculate (line 478) | def recalculate(self) -> None:
    method _mark_abandoned (line 505) | def _mark_abandoned(self) -> None:
    method effective_deadline (line 510) | def effective_deadline(self) -> float:
  class CancelScope (line 544) | class CancelScope:
    method __attrs_post_init__ (line 600) | def __attrs_post_init__(self) -> None:
    method __enter__ (line 613) | def __enter__(self) -> Self:
    method _close (line 633) | def _close(self, exc: BaseException | None) -> BaseException | None:
    method __exit__ (line 703) | def __exit__(
    method __repr__ (line 735) | def __repr__(self) -> str:
    method _might_change_registered_deadline (line 762) | def _might_change_registered_deadline(self) -> Iterator[None]:
    method deadline (line 786) | def deadline(self) -> float:
    method deadline (line 821) | def deadline(self, new_deadline: float) -> None:
    method relative_deadline (line 837) | def relative_deadline(self) -> float:
    method relative_deadline (line 860) | def relative_deadline(self, new_relative_deadline: float) -> None:
    method is_relative (line 877) | def is_relative(self) -> bool | None:
    method shield (line 886) | def shield(self) -> bool:
    method shield (line 911) | def shield(self, new_value: bool) -> None:
    method _cancel (line 919) | def _cancel(self, cancel_reason: CancelReason | None) -> None:
    method cancel (line 937) | def cancel(self, reason: str | None = None) -> None:
    method cancel_called (line 956) | def cancel_called(self) -> bool:
  class TaskStatus (line 992) | class TaskStatus(Protocol[StatusT_contra]):
    method started (line 999) | def started(self: TaskStatus[None]) -> None: ...
    method started (line 1002) | def started(self, value: StatusT_contra) -> None: ...
    method started (line 1004) | def started(self, value: StatusT_contra | None = None) -> None:
  class _TaskStatus (line 1014) | class _TaskStatus(TaskStatus[StatusT]):
    method __repr__ (line 1020) | def __repr__(self) -> str:
    method started (line 1024) | def started(self: _TaskStatus[None]) -> None: ...
    method started (line 1027) | def started(self: _TaskStatus[StatusT], value: StatusT) -> None: ...
    method started (line 1029) | def started(self, value: StatusT | None = None) -> None:
  class NurseryManager (line 1083) | class NurseryManager:
    method __aenter__ (line 1096) | async def __aenter__(self) -> Nursery:
    method __aexit__ (line 1107) | async def __aexit__(
    method __enter__ (line 1138) | def __enter__(self) -> NoReturn:
    method __exit__ (line 1143) | def __exit__(
  function open_nursery (line 1152) | def open_nursery(
  class Nursery (line 1192) | class Nursery(metaclass=NoPublicConstructor):
    method __init__ (line 1214) | def __init__(
    method child_tasks (line 1241) | def child_tasks(self) -> frozenset[Task]:
    method parent_task (line 1247) | def parent_task(self) -> Task:
    method _add_exc (line 1251) | def _add_exc(self, exc: BaseException, reason: CancelReason | None) ->...
    method _check_nursery_closed (line 1255) | def _check_nursery_closed(self) -> None:
    method _child_finished (line 1262) | def _child_finished(
    method _nested_child_finished (line 1282) | async def _nested_child_finished(
    method start_soon (line 1349) | def start_soon(
    method start (line 1397) | async def start(  # type: ignore[explicit-any]
    method __del__ (line 1486) | def __del__(self) -> None:
  class Task (line 1497) | class Task(metaclass=NoPublicConstructor):  # type: ignore[explicit-any]
    method __repr__ (line 1532) | def __repr__(self) -> str:
    method parent_nursery (line 1536) | def parent_nursery(self) -> Nursery | None:
    method eventual_parent_nursery (line 1547) | def eventual_parent_nursery(self) -> Nursery | None:
    method child_nurseries (line 1559) | def child_nurseries(self) -> list[Nursery]:
    method iter_await_frames (line 1567) | def iter_await_frames(self) -> Iterator[tuple[types.FrameType, int]]:
    method _activate_cancel_status (line 1626) | def _activate_cancel_status(self, cancel_status: CancelStatus | None) ...
    method _attempt_abort (line 1635) | def _attempt_abort(self, raise_cancel: _core.RaiseCancelT) -> None:
    method _attempt_delivery_of_any_pending_cancel (line 1654) | def _attempt_delivery_of_any_pending_cancel(self) -> None:
    method _attempt_delivery_of_pending_ki (line 1674) | def _attempt_delivery_of_pending_ki(self) -> None:
  class RunStatistics (line 1692) | class RunStatistics:
  class GuestState (line 1744) | class GuestState:  # type: ignore[explicit-any]
    method guest_tick (line 1752) | def guest_tick(self) -> None:
  class Runner (line 1795) | class Runner:  # type: ignore[explicit-any]
    method force_guest_tick_asap (line 1827) | def force_guest_tick_asap(self) -> None:
    method close (line 1833) | def close(self) -> None:
    method current_statistics (line 1843) | def current_statistics(self) -> RunStatistics:
    method current_time (line 1876) | def current_time(self) -> float:
    method current_clock (line 1889) | def current_clock(self) -> Clock:
    method current_root_task (line 1894) | def current_root_task(self) -> Task | None:
    method reschedule (line 1907) | def reschedule(
    method spawn_impl (line 1942) | def spawn_impl(
    method task_exited (line 2020) | def task_exited(self, task: Task, outcome: Outcome[object]) -> None:
    method spawn_system_task (line 2086) | def spawn_system_task(
    method init (line 2153) | async def init(
    method current_trio_token (line 2210) | def current_trio_token(self) -> TrioToken:
    method deliver_ki (line 2232) | def deliver_ki(self) -> None:
    method _deliver_ki_cb (line 2237) | def _deliver_ki_cb(self) -> None:
    method wait_all_tasks_blocked (line 2259) | async def wait_all_tasks_blocked(self, cushion: float = 0.0) -> None:
  function setup_runner (line 2395) | def setup_runner(
  function run (line 2433) | def run(
  function start_guest_run (line 2557) | def start_guest_run(  # type: ignore[explicit-any]
  function unrolled_run (line 2722) | def unrolled_run(
  class _TaskStatusIgnored (line 2974) | class _TaskStatusIgnored(TaskStatus[object]):
    method __repr__ (line 2975) | def __repr__(self) -> str:
    method started (line 2978) | def started(self, value: object = None) -> None:
  function current_task (line 2985) | def current_task() -> Task:
  function current_effective_deadline (line 2999) | def current_effective_deadline() -> float:
  function checkpoint (line 3026) | async def checkpoint() -> None:
  function checkpoint_if_cancelled (line 3064) | async def checkpoint_if_cancelled() -> None:
  function in_trio_run (line 3088) | def in_trio_run() -> bool:
  function in_trio_task (line 3097) | def in_trio_task() -> bool:

FILE: src/trio/_core/_run_context.py
  class RunContext (line 10) | class RunContext(threading.local):

FILE: src/trio/_core/_tests/test_asyncgen.py
  function test_asyncgen_basics (line 19) | def test_asyncgen_basics() -> None:
  function test_asyncgen_throws_during_finalization (line 96) | async def test_asyncgen_throws_during_finalization(
  function test_firstiter_after_closing (line 121) | def test_firstiter_after_closing() -> None:
  function test_interdependent_asyncgen_cleanup_order (line 147) | def test_interdependent_asyncgen_cleanup_order() -> None:
  function test_last_minute_gc_edge_case (line 189) | def test_last_minute_gc_edge_case() -> None:
  function step_outside_async_context (line 249) | async def step_outside_async_context(aiter_: AsyncGenerator[int, None]) ...
  function test_fallback_when_no_hook_claims_it (line 274) | async def test_fallback_when_no_hook_claims_it(
  function test_delegation_to_existing_hooks (line 304) | def test_delegation_to_existing_hooks() -> None:

FILE: src/trio/_core/_tests/test_cancelled.py
  function test_Cancelled_init (line 15) | def test_Cancelled_init() -> None:
  function test_Cancelled_str (line 26) | async def test_Cancelled_str() -> None:
  function test_Cancelled_subclass (line 53) | def test_Cancelled_subclass() -> None:
  function test_Cancelled_pickle (line 59) | def test_Cancelled_pickle() -> None:
  function test_cancel_reason (line 68) | async def test_cancel_reason() -> None:
  function cancelled_task (line 96) | async def cancelled_task(
  function test_cancel_reason_nursery (line 106) | async def test_cancel_reason_nursery() -> None:
  function test_cancel_reason_nursery2 (line 120) | async def test_cancel_reason_nursery2() -> None:
  function test_cancel_reason_nursery3 (line 133) | async def test_cancel_reason_nursery3() -> None:
  function test_cancel_reason_not_overwritten (line 157) | async def test_cancel_reason_not_overwritten() -> None:
  function test_cancel_reason_not_overwritten_2 (line 173) | async def test_cancel_reason_not_overwritten_2() -> None:
  function test_nested_child_source (line 183) | async def test_nested_child_source() -> None:
  function test_reason_delayed_ki (line 202) | async def test_reason_delayed_ki() -> None:

FILE: src/trio/_core/_tests/test_exceptiongroup_gc.py
  function raiser1 (line 20) | def raiser1() -> NoReturn:
  function raiser1_2 (line 24) | def raiser1_2() -> NoReturn:
  function raiser1_3 (line 28) | def raiser1_3() -> NoReturn:
  function raiser2 (line 32) | def raiser2() -> NoReturn:
  function raiser2_2 (line 36) | def raiser2_2() -> NoReturn:
  function get_exc (line 40) | def get_exc(raiser: Callable[[], NoReturn]) -> Exception:
  function get_tb (line 48) | def get_tb(raiser: Callable[[], NoReturn]) -> TracebackType | None:
  function test_concat_tb (line 52) | def test_concat_tb() -> None:
  function test_ExceptionGroup_catch_doesnt_create_cyclic_garbage (line 83) | def test_ExceptionGroup_catch_doesnt_create_cyclic_garbage() -> None:

FILE: src/trio/_core/_tests/test_guest_mode.py
  function trivial_guest_run (line 48) | def trivial_guest_run(
  function test_guest_trivial (line 119) | def test_guest_trivial() -> None:
  function test_guest_can_do_io (line 133) | def test_guest_can_do_io() -> None:
  function test_guest_is_initialized_when_start_returns (line 153) | def test_guest_is_initialized_when_start_returns() -> None:
  function test_host_can_directly_wake_trio_task (line 203) | def test_host_can_directly_wake_trio_task() -> None:
  function test_host_altering_deadlines_wakes_trio_up (line 213) | def test_host_altering_deadlines_wakes_trio_up() -> None:
  function test_guest_mode_sniffio_integration (line 236) | def test_guest_mode_sniffio_integration() -> None:
  function test_guest_mode_trio_context_detection (line 266) | def test_guest_mode_trio_context_detection() -> None:
  function test_warn_set_wakeup_fd_overwrite (line 286) | def test_warn_set_wakeup_fd_overwrite() -> None:
  function test_host_wakeup_doesnt_trigger_wait_all_tasks_blocked (line 350) | def test_host_wakeup_doesnt_trigger_wait_all_tasks_blocked() -> None:
  function test_guest_warns_if_abandoned (line 426) | def test_guest_warns_if_abandoned() -> None:
  function aiotrio_run (line 470) | def aiotrio_run(
  function test_guest_mode_on_asyncio (line 516) | def test_guest_mode_on_asyncio() -> None:
  function test_guest_mode_internal_errors (line 580) | def test_guest_mode_internal_errors(
  function test_guest_mode_ki (line 627) | def test_guest_mode_ki() -> None:
  function test_guest_mode_autojump_clock_threshold_changing (line 659) | def test_guest_mode_autojump_clock_threshold_changing() -> None:
  function test_guest_mode_asyncgens (line 683) | def test_guest_mode_asyncgens() -> None:
  function test_guest_mode_asyncgens_garbage_collection (line 716) | def test_guest_mode_asyncgens_garbage_collection() -> None:

FILE: src/trio/_core/_tests/test_instrumentation.py
  class TaskRecorder (line 18) | class TaskRecorder(_abc.Instrument):
    method before_run (line 21) | def before_run(self) -> None:
    method task_scheduled (line 24) | def task_scheduled(self, task: Task) -> None:
    method before_task_step (line 27) | def before_task_step(self, task: Task) -> None:
    method after_task_step (line 31) | def after_task_step(self, task: Task) -> None:
    method after_run (line 35) | def after_run(self) -> None:
    method filter_tasks (line 38) | def filter_tasks(self, tasks: Container[Task]) -> Iterable[tuple[str, ...
  function test_instruments (line 46) | def test_instruments(recwarn: object) -> None:
  function test_instruments_interleave (line 91) | def test_instruments_interleave() -> None:
  function test_null_instrument (line 134) | def test_null_instrument() -> None:
  function test_instrument_before_after_run (line 146) | def test_instrument_before_after_run() -> None:
  function test_instrument_task_spawn_exit (line 163) | def test_instrument_task_spawn_exit() -> None:
  function test_instruments_crash (line 183) | def test_instruments_crash(caplog: pytest.LogCaptureFixture) -> None:
  function test_instruments_monkeypatch (line 215) | def test_instruments_monkeypatch() -> None:
  function test_instrument_that_raises_on_getattr (line 250) | def test_instrument_that_raises_on_getattr() -> None:
  function test_instrument_call_trio_context (line 271) | def test_instrument_call_trio_context() -> None:

FILE: src/trio/_core/_tests/test_io.py
  function fill_socket (line 28) | def fill_socket(sock: stdlib_socket.socket) -> None:
  function drain_socket (line 36) | def drain_socket(sock: stdlib_socket.socket) -> None:
  function socketpair (line 50) | def socketpair() -> Generator[SocketPair, None, None]:
  function also_using_fileno (line 59) | def also_using_fileno(
  function test_wait_basic (line 96) | async def test_wait_basic(
  function test_double_read (line 166) | async def test_double_read(socketpair: SocketPair, wait_readable: WaitSo...
  function test_double_write (line 179) | async def test_double_write(socketpair: SocketPair, wait_writable: WaitS...
  function test_interrupted_by_close (line 195) | async def test_interrupted_by_close(
  function test_socket_simultaneous_read_write (line 222) | async def test_socket_simultaneous_read_write(
  function test_socket_actual_streaming (line 254) | async def test_socket_actual_streaming(
  function test_notify_closing_on_invalid_object (line 307) | async def test_notify_closing_on_invalid_object() -> None:
  function test_wait_on_invalid_object (line 323) | async def test_wait_on_invalid_object() -> None:
  function test_io_manager_statistics (line 338) | async def test_io_manager_statistics() -> None:
  function test_io_manager_kqueue_monitors_statistics (line 388) | async def test_io_manager_kqueue_monitors_statistics() -> None:
  function test_can_survive_unnotified_close (line 425) | async def test_can_survive_unnotified_close() -> None:

FILE: src/trio/_core/_tests/test_ki.py
  function ki_self (line 40) | def ki_self() -> None:
  function test_ki_self (line 44) | def test_ki_self() -> None:
  function test_ki_enabled (line 49) | async def test_ki_enabled() -> None:
  function test_ki_enabled_after_yield_briefly (line 118) | async def test_ki_enabled_after_yield_briefly() -> None:
  function test_generator_based_context_manager_throw (line 142) | async def test_generator_based_context_manager_throw() -> None:
  function test_async_generator_agen_protection (line 163) | async def test_async_generator_agen_protection() -> None:
  function test_native_agen_protection (line 207) | async def test_native_agen_protection() -> None:
  function _check_agen (line 229) | async def _check_agen(agen_fn: Callable[[], AsyncIterator[None]]) -> None:
  function test_ki_disabled_out_of_context (line 247) | def test_ki_disabled_out_of_context() -> None:
  function test_ki_disabled_in_del (line 251) | def test_ki_disabled_in_del() -> None:
  function test_ki_protection_works (line 270) | def test_ki_protection_works() -> None:
  function test_ki_is_good_neighbor (line 490) | def test_ki_is_good_neighbor() -> None:
  function test_ki_with_broken_threads (line 511) | def test_ki_with_broken_threads() -> None:
  function _identity (line 534) | def _identity(v: _T) -> _T:
  function test_ki_does_not_leak_across_different_calls_to_inner_functions (line 546) | async def test_ki_does_not_leak_across_different_calls_to_inner_function...
  function test_ki_protection_check_does_not_freeze_locals (line 562) | async def test_ki_protection_check_does_not_freeze_locals() -> None:
  function test_identity_weakref_internals (line 575) | def test_identity_weakref_internals() -> None:
  function test_weak_key_identity_dict_remove_callback_keyerror (line 595) | def test_weak_key_identity_dict_remove_callback_keyerror() -> None:
  function test_weak_key_identity_dict_remove_callback_selfref_expired (line 616) | def test_weak_key_identity_dict_remove_callback_selfref_expired() -> None:
  function _protected_async_gen_fn (line 640) | async def _protected_async_gen_fn() -> AsyncGenerator[None, None]:
  function _protected_async_fn (line 645) | async def _protected_async_fn() -> None:
  function _protected_gen_fn (line 650) | def _protected_gen_fn() -> Generator[None, None, None]:
  function _unprotected_async_gen_fn (line 655) | async def _unprotected_async_gen_fn() -> AsyncGenerator[None, None]:
  function _unprotected_async_fn (line 660) | async def _unprotected_async_fn() -> None:
  function _unprotected_gen_fn (line 665) | def _unprotected_gen_fn() -> Generator[None, None, None]:
  function _consume_async_generator (line 669) | async def _consume_async_generator(agen: AsyncGenerator[None, None]) -> ...
  function _consume_function_for_coverage (line 678) | def _consume_function_for_coverage(
  function test_enable_disable_ki_protection_passes_on_inspect_flags (line 691) | def test_enable_disable_ki_protection_passes_on_inspect_flags() -> None:

FILE: src/trio/_core/_tests/test_local.py
  function test_runvar_smoketest (line 10) | def test_runvar_smoketest() -> None:
  function test_runvar_resetting (line 39) | def test_runvar_resetting() -> None:
  function test_runvar_sync (line 72) | def test_runvar_sync() -> None:
  function test_accessing_runvar_outside_run_call_fails (line 103) | def test_accessing_runvar_outside_run_call_fails() -> None:

FILE: src/trio/_core/_tests/test_mock_clock.py
  function test_mock_clock (line 15) | def test_mock_clock() -> None:
  function test_mock_clock_autojump (line 59) | async def test_mock_clock_autojump(mock_clock: MockClock) -> None:
  function test_mock_clock_autojump_interference (line 100) | async def test_mock_clock_autojump_interference(mock_clock: MockClock) -...
  function test_mock_clock_autojump_preset (line 118) | def test_mock_clock_autojump_preset() -> None:
  function test_mock_clock_autojump_0_and_wait_all_tasks_blocked_0 (line 128) | async def test_mock_clock_autojump_0_and_wait_all_tasks_blocked_0(
  function test_mock_clock_autojump_0_and_wait_all_tasks_blocked_nonzero (line 156) | async def test_mock_clock_autojump_0_and_wait_all_tasks_blocked_nonzero(
  function test_initialization_doesnt_mutate_runner (line 181) | async def test_initialization_doesnt_mutate_runner() -> None:

FILE: src/trio/_core/_tests/test_parking_lot.py
  function test_parking_lot_basic (line 23) | async def test_parking_lot_basic() -> None:
  function cancellable_waiter (line 98) | async def cancellable_waiter(
  function test_parking_lot_cancel (line 115) | async def test_parking_lot_cancel() -> None:
  function test_parking_lot_repark (line 142) | async def test_parking_lot_repark() -> None:
  function test_parking_lot_repark_with_count (line 196) | async def test_parking_lot_repark_with_count() -> None:
  function dummy_task (line 228) | async def dummy_task(
  function test_parking_lot_breaker_basic (line 235) | async def test_parking_lot_breaker_basic() -> None:
  function test_parking_lot_break_parking_tasks (line 257) | async def test_parking_lot_break_parking_tasks() -> None:
  function test_parking_lot_breaker_registration (line 282) | async def test_parking_lot_breaker_registration() -> None:
  function test_parking_lot_breaker_rebreak (line 320) | async def test_parking_lot_breaker_rebreak() -> None:
  function test_parking_lot_multiple_breakers_exit (line 335) | async def test_parking_lot_multiple_breakers_exit() -> None:
  function test_parking_lot_breaker_register_exited_task (line 354) | async def test_parking_lot_breaker_register_exited_task() -> None:
  function test_parking_lot_break_itself (line 370) | async def test_parking_lot_break_itself() -> None:

FILE: src/trio/_core/_tests/test_run.py
  function sleep_forever (line 63) | async def sleep_forever() -> object:
  function not_none (line 67) | def not_none(x: T | None) -> T:
  function test_basic (line 76) | def test_basic() -> None:
  function test_initial_task_error (line 97) | def test_initial_task_error() -> None:
  function test_run_nesting (line 106) | def test_run_nesting() -> None:
  function test_nursery_warn_use_async_with (line 118) | async def test_nursery_warn_use_async_with() -> None:
  function test_nursery_main_block_error_basic (line 132) | async def test_nursery_main_block_error_basic() -> None:
  function test_child_crash_basic (line 140) | async def test_child_crash_basic() -> None:
  function test_basic_interleave (line 152) | async def test_basic_interleave() -> None:
  function test_task_crash_propagation (line 169) | def test_task_crash_propagation() -> None:
  function test_main_and_task_both_crash (line 194) | def test_main_and_task_both_crash() -> None:
  function test_two_child_crashes (line 209) | def test_two_child_crashes() -> None:
  function test_child_crash_wakes_parent (line 222) | async def test_child_crash_wakes_parent() -> None:
  function test_reschedule (line 232) | async def test_reschedule() -> None:
  function test_current_time (line 264) | async def test_current_time() -> None:
  function test_current_time_with_mock_clock (line 273) | async def test_current_time_with_mock_clock(mock_clock: _core.MockClock)...
  function test_current_clock (line 281) | async def test_current_clock(mock_clock: _core.MockClock) -> None:
  function test_current_task (line 285) | async def test_current_task() -> None:
  function test_root_task (line 295) | async def test_root_task() -> None:
  function test_out_of_context (line 300) | def test_out_of_context() -> None:
  function test_current_statistics (line 307) | async def test_current_statistics(mock_clock: _core.MockClock) -> None:
  function test_cancel_scope_repr (line 357) | async def test_cancel_scope_repr(mock_clock: _core.MockClock) -> None:
  function test_cancel_scope_validation (line 373) | async def test_cancel_scope_validation() -> None:
  function test_cancel_points (line 403) | def test_cancel_points() -> None:
  function test_cancel_edge_cases (line 441) | async def test_cancel_edge_cases() -> None:
  function test_cancel_scope_exceptiongroup_filtering (line 459) | async def test_cancel_scope_exceptiongroup_filtering() -> None:
  function test_precancelled_task (line 496) | async def test_precancelled_task() -> None:
  function test_cancel_shielding (line 512) | async def test_cancel_shielding() -> None:
  function test_cancel_inheritance (line 553) | async def test_cancel_inheritance() -> None:
  function test_cancel_shield_abort (line 575) | async def test_cancel_shield_abort() -> None:
  function test_basic_timeout (line 606) | async def test_basic_timeout(mock_clock: _core.MockClock) -> None:
  function test_cancel_scope_nesting (line 643) | async def test_cancel_scope_nesting() -> None:
  function test_unshield_while_cancel_propagating (line 682) | async def test_unshield_while_cancel_propagating() -> None:
  function test_cancel_unbound (line 694) | async def test_cancel_unbound() -> None:
  function test_cancel_scope_misnesting_1 (line 768) | async def test_cancel_scope_misnesting_1() -> None:
  function test_cancel_scope_misnesting_2 (line 779) | async def test_cancel_scope_misnesting_2() -> None:
  function test_cancel_scope_misnesting_3 (line 838) | async def test_cancel_scope_misnesting_3() -> None:
  function no_cause_or_context (line 856) | def no_cause_or_context(e: BaseException) -> bool:
  function test_nursery_misnest (line 860) | async def test_nursery_misnest() -> None:
  function test_nursery_nested_child_misnest (line 877) | def test_nursery_nested_child_misnest() -> None:
  function test_asyncexitstack_nursery_misnest (line 896) | async def test_asyncexitstack_nursery_misnest() -> None:
  function test_asyncexitstack_nursery_misnest_cleanup (line 933) | def test_asyncexitstack_nursery_misnest_cleanup() -> None:
  function test_timekeeping (line 980) | async def test_timekeeping() -> None:
  function test_failed_abort (line 1000) | async def test_failed_abort() -> None:
  function test_broken_abort (line 1033) | def test_broken_abort() -> None:
  function test_error_in_run_loop (line 1066) | def test_error_in_run_loop() -> None:
  function test_spawn_system_task (line 1078) | async def test_spawn_system_task() -> None:
  function test_system_task_crash (line 1092) | def test_system_task_crash() -> None:
  function test_system_task_crash_ExceptionGroup (line 1104) | def test_system_task_crash_ExceptionGroup() -> None:
  function test_system_task_crash_plus_Cancelled (line 1134) | def test_system_task_crash_plus_Cancelled() -> None:
  function test_system_task_crash_KeyboardInterrupt (line 1166) | def test_system_task_crash_KeyboardInterrupt() -> None:
  function test_yield_briefly_checks_for_timeout (line 1191) | async def test_yield_briefly_checks_for_timeout(mock_clock: _core.MockCl...
  function test_exc_info (line 1205) | async def test_exc_info() -> None:
  function test_exc_info_after_throw_suppressed (line 1273) | async def test_exc_info_after_throw_suppressed() -> None:
  function test_exception_chaining_after_throw (line 1303) | async def test_exception_chaining_after_throw() -> None:
  function test_exc_info_after_throw_to_inner_suppressed (line 1336) | async def test_exc_info_after_throw_to_inner_suppressed() -> None:
  function test_exception_chaining_after_throw_to_inner (line 1368) | async def test_exception_chaining_after_throw_to_inner() -> None:
  function test_nursery_exception_chaining_doesnt_make_context_loops (line 1403) | async def test_nursery_exception_chaining_doesnt_make_context_loops() ->...
  function test_TrioToken_identity (line 1416) | def test_TrioToken_identity() -> None:
  function test_TrioToken_run_sync_soon_basic (line 1430) | async def test_TrioToken_run_sync_soon_basic() -> None:
  function test_TrioToken_run_sync_soon_too_late (line 1443) | def test_TrioToken_run_sync_soon_too_late() -> None:
  function test_TrioToken_run_sync_soon_idempotent (line 1455) | async def test_TrioToken_run_sync_soon_idempotent() -> None:
  function test_TrioToken_run_sync_soon_idempotent_requeue (line 1482) | def test_TrioToken_run_sync_soon_idempotent_requeue() -> None:
  function test_TrioToken_run_sync_soon_after_main_crash (line 1506) | def test_TrioToken_run_sync_soon_after_main_crash() -> None:
  function test_TrioToken_run_sync_soon_crashes (line 1522) | def test_TrioToken_run_sync_soon_crashes() -> None:
  function test_TrioToken_run_sync_soon_FIFO (line 1546) | async def test_TrioToken_run_sync_soon_FIFO() -> None:
  function test_TrioToken_run_sync_soon_starvation_resistance (line 1556) | def test_TrioToken_run_sync_soon_starvation_resistance() -> None:
  function test_TrioToken_run_sync_soon_threaded_stress_test (line 1584) | def test_TrioToken_run_sync_soon_threaded_stress_test() -> None:
  function test_TrioToken_run_sync_soon_massive_queue (line 1612) | async def test_TrioToken_run_sync_soon_massive_queue() -> None:
  function test_TrioToken_run_sync_soon_late_crash (line 1634) | def test_TrioToken_run_sync_soon_late_crash() -> None:
  function test_slow_abort_basic (line 1660) | async def test_slow_abort_basic() -> None:
  function test_slow_abort_edge_cases (line 1676) | async def test_slow_abort_edge_cases() -> None:
  function test_task_tree_introspection (line 1719) | async def test_task_tree_introspection() -> None:
  function test_nursery_closure (line 1791) | async def test_nursery_closure() -> None:
  function test_spawn_name (line 1808) | async def test_spawn_name() -> None:
  function test_current_effective_deadline (line 1830) | async def test_current_effective_deadline(mock_clock: _core.MockClock) -...
  function test_nice_error_on_bad_calls_to_run_or_spawn (line 1852) | def test_nice_error_on_bad_calls_to_run_or_spawn() -> None:
  function test_calling_asyncio_function_gives_nice_error (line 1904) | def test_calling_asyncio_function_gives_nice_error() -> None:
  function test_asyncio_function_inside_nursery_does_not_explode (line 1920) | async def test_asyncio_function_inside_nursery_does_not_explode() -> None:
  function test_trivial_yields (line 1928) | async def test_trivial_yields() -> None:
  function test_nursery_start (line 1967) | async def test_nursery_start(autojump_clock: _core.MockClock) -> None:
  function test_task_nursery_stack (line 2095) | async def test_task_nursery_stack() -> None:
  function test_nursery_start_with_cancelled_nursery (line 2108) | async def test_nursery_start_with_cancelled_nursery() -> None:
  function test_nursery_start_keeps_nursery_open (line 2152) | async def test_nursery_start_keeps_nursery_open(
  function test_nursery_explicit_exception (line 2197) | async def test_nursery_explicit_exception() -> None:
  function test_nursery_stop_iteration (line 2203) | async def test_nursery_stop_iteration() -> None:
  function test_nursery_stop_async_iteration (line 2213) | async def test_nursery_stop_async_iteration() -> None:
  function test_traceback_frame_removal (line 2270) | async def test_traceback_frame_removal() -> None:
  function test_contextvar_support (line 2291) | def test_contextvar_support() -> None:
  function test_contextvar_multitask (line 2310) | async def test_contextvar_multitask() -> None:
  function test_system_task_contexts (line 2330) | def test_system_task_contexts() -> None:
  function test_Nursery_init (line 2350) | async def test_Nursery_init() -> None:
  function test_Nursery_private_init (line 2360) | async def test_Nursery_private_init() -> None:
  function test_Nursery_subclass (line 2366) | def test_Nursery_subclass() -> None:
  function test_CancelScope_subclass (line 2371) | def test_CancelScope_subclass() -> None:
  function test_sniffio_integration (line 2376) | def test_sniffio_integration() -> None:
  function test_Task_custom_sleep_data (line 2414) | async def test_Task_custom_sleep_data() -> None:
  function async_yield (line 2424) | def async_yield(value: T) -> Generator[T, None, None]:
  function test_permanently_detach_coroutine_object (line 2428) | async def test_permanently_detach_coroutine_object() -> None:
  function test_detach_and_reattach_coroutine_object (line 2482) | async def test_detach_and_reattach_coroutine_object() -> None:
  function test_detached_coroutine_cancellation (line 2530) | async def test_detached_coroutine_cancellation() -> None:
  function test_async_function_implemented_in_C (line 2562) | def test_async_function_implemented_in_C() -> None:
  function test_very_deep_cancel_scope_nesting (line 2586) | async def test_very_deep_cancel_scope_nesting() -> None:
  function test_cancel_scope_deadline_duplicates (line 2596) | async def test_cancel_scope_deadline_duplicates() -> None:
  function test_simple_cancel_scope_usage_doesnt_create_cyclic_garbage (line 2614) | async def test_simple_cancel_scope_usage_doesnt_create_cyclic_garbage() ...
  function test_cancel_scope_exit_doesnt_create_cyclic_garbage (line 2656) | async def test_cancel_scope_exit_doesnt_create_cyclic_garbage() -> None:
  function test_nursery_cancel_doesnt_create_cyclic_garbage (line 2694) | async def test_nursery_cancel_doesnt_create_cyclic_garbage() -> None:
  function test_locals_destroyed_promptly_on_cancel (line 2731) | async def test_locals_destroyed_promptly_on_cancel() -> None:
  function _create_kwargs (line 2752) | def _create_kwargs(strictness: bool | None) -> dict[str, bool]:
  function test_setting_strict_exception_groups (line 2766) | def test_setting_strict_exception_groups(
  function test_nursery_collapse (line 2809) | async def test_nursery_collapse(strict: bool | None) -> None:
  function test_cancel_scope_no_cancellederror (line 2833) | async def test_cancel_scope_no_cancellederror() -> None:
  function test_trio_run_strict_before_started (line 2854) | def test_trio_run_strict_before_started(
  function test_start_exception_preserves_cause_and_context (line 2923) | async def test_start_exception_preserves_cause_and_context() -> None:
  function test_internal_error_old_nursery_multiple_tasks (line 2944) | async def test_internal_error_old_nursery_multiple_tasks() -> None:
  function no_other_refs (line 2962) | def no_other_refs() -> list[object]:
  function no_other_refs (line 2967) | def no_other_refs() -> list[object]:
  function test_ki_protection_doesnt_leave_cyclic_garbage (line 2979) | async def test_ki_protection_doesnt_leave_cyclic_garbage() -> None:
  function test_context_run_tb_frames (line 3008) | def test_context_run_tb_frames() -> None:
  function test_trio_context_detection (line 3018) | def test_trio_context_detection() -> None:

FILE: src/trio/_core/_tests/test_thread_cache.py
  function test_thread_cache_basics (line 22) | def test_thread_cache_basics() -> None:
  function test_thread_cache_deref (line 38) | def test_thread_cache_deref() -> None:
  function test_spawning_new_thread_from_deliver_reuses_starting_thread (line 62) | def test_spawning_new_thread_from_deliver_reuses_starting_thread() -> None:
  function test_idle_threads_exit (line 97) | def test_idle_threads_exit(monkeypatch: pytest.MonkeyPatch) -> None:
  function _join_started_threads (line 113) | def _join_started_threads() -> Iterator[None]:
  function test_race_between_idle_exit_and_job_assignment (line 124) | def test_race_between_idle_exit_and_job_assignment(
  function test_raise_in_deliver (line 179) | def test_raise_in_deliver(capfd: pytest.CaptureFixture[str]) -> None:
  function test_clear_thread_cache_after_fork (line 202) | def test_clear_thread_cache_after_fork() -> None:

FILE: src/trio/_core/_tests/test_tutil.py
  function test_check_sequence_matches (line 6) | def test_check_sequence_matches() -> None:

FILE: src/trio/_core/_tests/test_unbounded_queue.py
  function test_UnboundedQueue_basic (line 15) | async def test_UnboundedQueue_basic() -> None:
  function test_UnboundedQueue_blocking (line 40) | async def test_UnboundedQueue_blocking() -> None:
  function test_UnboundedQueue_fairness (line 72) | async def test_UnboundedQueue_fairness() -> None:
  function test_UnboundedQueue_trivial_yields (line 119) | async def test_UnboundedQueue_trivial_yields() -> None:
  function test_UnboundedQueue_no_spurious_wakeups (line 132) | async def test_UnboundedQueue_no_spurious_wakeups() -> None:

FILE: src/trio/_core/_tests/test_windows.py
  function test_winerror (line 39) | def test_winerror(monkeypatch: pytest.MonkeyPatch) -> None:
  function test_completion_key_listen (line 92) | async def test_completion_key_listen() -> None:
  function test_readinto_overlapped (line 121) | async def test_readinto_overlapped() -> None:
  function pipe_with_overlapped_read (line 172) | def pipe_with_overlapped_read() -> Generator[tuple[BufferedWriter, int],...
  function test_forgot_to_register_with_iocp (line 186) | def test_forgot_to_register_with_iocp() -> None:
  function test_too_late_to_cancel (line 223) | async def test_too_late_to_cancel() -> None:
  function test_lsp_that_hooks_select_gives_good_error (line 251) | def test_lsp_that_hooks_select_gives_good_error(
  function test_lsp_that_completely_hides_base_socket_gives_good_error (line 277) | def test_lsp_that_completely_hides_base_socket_gives_good_error(

FILE: src/trio/_core/_tests/tutil.py
  function gc_collect_harder (line 48) | def gc_collect_harder() -> None:
  function ignore_coroutine_never_awaited_warnings (line 67) | def ignore_coroutine_never_awaited_warnings() -> Generator[None, None, N...
  function _noop (line 78) | def _noop(*args: object, **kwargs: object) -> None:
  function restore_unraisablehook (line 83) | def restore_unraisablehook() -> Generator[None, None, None]:
  function check_sequence_matches (line 95) | def check_sequence_matches(seq: Sequence[T], template: Iterable[T | set[...
  function create_asyncio_future_in_new_loop (line 115) | def create_asyncio_future_in_new_loop() -> asyncio.Future[object]:

FILE: src/trio/_core/_tests/type_tests/nursery_start.py
  function task_0 (line 11) | async def task_0() -> None: ...
  function task_1a (line 14) | async def task_1a(value: int) -> None: ...
  function task_1b (line 17) | async def task_1b(value: str) -> None: ...
  function task_2a (line 20) | async def task_2a(a: int, b: str) -> None: ...
  function task_2b (line 23) | async def task_2b(a: str, b: int) -> None: ...
  function task_2c (line 26) | async def task_2c(a: str, b: int, optional: bool = False) -> None: ...
  function task_requires_kw (line 29) | async def task_requires_kw(a: int, *, b: bool) -> None: ...
  function task_startable_1 (line 32) | async def task_startable_1(
  function task_startable_2 (line 39) | async def task_startable_2(
  function task_requires_start (line 47) | async def task_requires_start(*, task_status: TaskStatus[str]) -> None:
  function task_pos_or_kw (line 51) | async def task_pos_or_kw(value: str, task_status: TaskStatus[int]) -> None:
  function check_start_soon (line 55) | def check_start_soon(nursery: Nursery) -> None:

FILE: src/trio/_core/_tests/type_tests/run.py
  function sleep_sort (line 12) | async def sleep_sort(values: Sequence[float]) -> list[float]:
  function has_optional (line 16) | async def has_optional(arg: int | None = None) -> int:
  function foo_overloaded (line 21) | async def foo_overloaded(arg: int) -> str: ...
  function foo_overloaded (line 25) | async def foo_overloaded(arg: str) -> int: ...
  function foo_overloaded (line 28) | async def foo_overloaded(arg: int | str) -> int | str:

FILE: src/trio/_core/_thread_cache.py
  function _to_os_thread_name (line 21) | def _to_os_thread_name(name: str) -> bytes:
  function get_os_thread_name_func (line 28) | def get_os_thread_name_func() -> Callable[[int | None, str], None] | None:
  class WorkerThread (line 132) | class WorkerThread(Generic[RetT]):
    method __init__ (line 135) | def __init__(self, thread_cache: ThreadCache) -> None:
    method _handle_job (line 161) | def _handle_job(self) -> None:
    method _work (line 192) | def _work(self) -> None:
  class ThreadCache (line 215) | class ThreadCache:
    method __init__ (line 218) | def __init__(self) -> None:
    method start_thread_soon (line 221) | def start_thread_soon(
  function start_thread_soon (line 239) | def start_thread_soon(
  function clear_worker_threads (line 306) | def clear_worker_threads() -> (

FILE: src/trio/_core/_traps.py
  class CancelShieldedCheckpoint (line 34) | class CancelShieldedCheckpoint:
  class WaitTaskRescheduled (line 40) | class WaitTaskRescheduled:
  class PermanentlyDetachCoroutineObject (line 46) | class PermanentlyDetachCoroutineObject:
  function _real_async_yield (line 66) | def _real_async_yield(
  function cancel_shielded_checkpoint (line 82) | async def cancel_shielded_checkpoint() -> None:
  class Abort (line 99) | class Abort(enum.Enum):
  function wait_task_rescheduled (line 115) | async def wait_task_rescheduled(  # type: ignore[explicit-any]
  function permanently_detach_coroutine_object (line 219) | async def permanently_detach_coroutine_object(
  function temporarily_detach_coroutine_object (line 252) | async def temporarily_detach_coroutine_object(
  function reattach_detached_coroutine_object (line 290) | async def reattach_detached_coroutine_object(task: Task, yield_value: ob...

FILE: src/trio/_core/_unbounded_queue.py
  class UnboundedQueueStatistics (line 18) | class UnboundedQueueStatistics:
  class UnboundedQueue (line 34) | class UnboundedQueue(Generic[T]):
    method __init__ (line 71) | def __init__(self) -> None:
    method __repr__ (line 77) | def __repr__(self) -> str:
    method qsize (line 80) | def qsize(self) -> int:
    method empty (line 84) | def empty(self) -> bool:
    method put_nowait (line 94) | def put_nowait(self, obj: T) -> None:
    method _get_batch_protected (line 112) | def _get_batch_protected(self) -> list[T]:
    method get_batch_nowait (line 118) | def get_batch_nowait(self) -> list[T]:
    method get_batch (line 134) | async def get_batch(self) -> list[T]:
    method statistics (line 152) | def statistics(self) -> UnboundedQueueStatistics:
    method __aiter__ (line 159) | def __aiter__(self) -> Self:
    method __anext__ (line 162) | async def __anext__(self) -> list[T]:

FILE: src/trio/_core/_wakeup_socketpair.py
  class WakeupSocketpair (line 12) | class WakeupSocketpair:
    method __init__ (line 13) | def __init__(self) -> None:
    method wakeup_thread_and_signal_safe (line 37) | def wakeup_thread_and_signal_safe(self) -> None:
    method wait_woken (line 41) | async def wait_woken(self) -> None:
    method drain (line 45) | def drain(self) -> None:
    method wakeup_on_signals (line 52) | def wakeup_on_signals(self) -> None:
    method close (line 71) | def close(self) -> None:

FILE: src/trio/_core/_windows_cffi.py
  class _Kernel32 (line 27) | class _Kernel32(Protocol):
    method CreateIoCompletionPort (line 30) | def CreateIoCompletionPort(
    method CreateEventA (line 39) | def CreateEventA(
    method SetFileCompletionNotificationModes (line 48) | def SetFileCompletionNotificationModes(
    method PostQueuedCompletionStatus (line 55) | def PostQueuedCompletionStatus(
    method CancelIoEx (line 64) | def CancelIoEx(
    method WriteFile (line 71) | def WriteFile(
    method ReadFile (line 82) | def ReadFile(
    method GetQueuedCompletionStatusEx (line 93) | def GetQueuedCompletionStatusEx(
    method CreateFileW (line 104) | def CreateFileW(
    method WaitForSingleObject (line 116) | def WaitForSingleObject(self, hHandle: Handle, dwMilliseconds: int, /)...
    method WaitForMultipleObjects (line 118) | def WaitForMultipleObjects(
    method SetEvent (line 127) | def SetEvent(self, handle: Handle, /) -> None: ...
    method CloseHandle (line 129) | def CloseHandle(self, handle: Handle, /) -> bool: ...
    method DeviceIoControl (line 131) | def DeviceIoControl(
  class _Nt (line 147) | class _Nt(Protocol):
    method RtlNtStatusToDosError (line 150) | def RtlNtStatusToDosError(self, status: int, /) -> ErrorCodes: ...
  class _Ws2 (line 153) | class _Ws2(Protocol):
    method WSAGetLastError (line 156) | def WSAGetLastError(self) -> int: ...
    method WSAIoctl (line 158) | def WSAIoctl(
  class _DummyStruct (line 174) | class _DummyStruct(Protocol):
  class _DummyUnion (line 179) | class _DummyUnion(Protocol):
  class _Overlapped (line 184) | class _Overlapped(Protocol):
  class ErrorCodes (line 206) | class ErrorCodes(enum.IntEnum):
  class FileFlags (line 221) | class FileFlags(enum.IntFlag):
  class AFDPollFlags (line 235) | class AFDPollFlags(enum.IntFlag):
  class WSAIoctls (line 255) | class WSAIoctls(enum.IntEnum):
  class CompletionModes (line 261) | class CompletionModes(enum.IntFlag):
  class IoControlCodes (line 266) | class IoControlCodes(enum.IntEnum):
  function _handle (line 275) | def _handle(obj: int | CData) -> Handle:
  function handle_array (line 287) | def handle_array(count: int) -> HandleArray:
  function raise_winerror (line 292) | def raise_winerror(

FILE: src/trio/_deprecate.py
  class TrioDeprecationWarning (line 27) | class TrioDeprecationWarning(FutureWarning):
  function _url_for_issue (line 45) | def _url_for_issue(issue: int) -> str:
  function _stringify (line 49) | def _stringify(thing: object) -> str:
  function warn_deprecated (line 55) | def warn_deprecated(
  function deprecated (line 81) | def deprecated(
  function deprecated_alias (line 126) | def deprecated_alias(
  class DeprecatedAttribute (line 146) | class DeprecatedAttribute:
  function deprecate_attributes (line 155) | def deprecate_attributes(

FILE: src/trio/_dtls.py
  function packet_header_overhead (line 45) | def packet_header_overhead(sock: SocketType) -> int:
  function worst_case_mtu (line 52) | def worst_case_mtu(sock: SocketType) -> int:
  function best_guess_mtu (line 59) | def best_guess_mtu(sock: SocketType) -> int:
  class ContentType (line 66) | class ContentType(enum.IntEnum):
  class HandshakeType (line 74) | class HandshakeType(enum.IntEnum):
  class ProtocolVersion (line 98) | class ProtocolVersion:
  class BadPacket (line 111) | class BadPacket(Exception):
  function part_of_handshake_untrusted (line 121) | def part_of_handshake_untrusted(packet: bytes) -> bool:
  function is_client_hello_untrusted (line 128) | def is_client_hello_untrusted(packet: bytes) -> bool:
  function to_hex (line 151) | def to_hex(data: bytes) -> str:  # pragma: no cover
  class Record (line 156) | class Record:
  function records_untrusted (line 163) | def records_untrusted(packet: bytes) -> Iterator[Record]:
  function encode_record (line 181) | def encode_record(record: Record) -> bytes:
  class HandshakeFragment (line 201) | class HandshakeFragment:
  function decode_handshake_fragment_untrusted (line 210) | def decode_handshake_fragment_untrusted(payload: bytes) -> HandshakeFrag...
  function encode_handshake_fragment (line 240) | def encode_handshake_fragment(hsf: HandshakeFragment) -> bytes:
  function decode_client_hello_untrusted (line 251) | def decode_client_hello_untrusted(packet: bytes) -> tuple[int, bytes, by...
  class HandshakeMessage (line 321) | class HandshakeMessage:
  class PseudoHandshakeMessage (line 331) | class PseudoHandshakeMessage:
  class OpaqueHandshakeMessage (line 343) | class OpaqueHandshakeMessage:
  function decode_volley_trusted (line 356) | def decode_volley_trusted(
  class RecordEncoder (line 404) | class RecordEncoder:
    method __init__ (line 405) | def __init__(self) -> None:
    method set_first_record_number (line 408) | def set_first_record_number(self, n: int) -> None:
    method encode_volley (line 411) | def encode_volley(
  function _current_cookie_tick (line 547) | def _current_cookie_tick() -> int:
  function _signable (line 553) | def _signable(*fields: bytes) -> bytes:
  function _make_cookie (line 560) | def _make_cookie(
  function valid_cookie (line 582) | def valid_cookie(
  function challenge_for (line 612) | def challenge_for(
  class _Queue (line 660) | class _Queue(Generic[_T]):
    method __init__ (line 661) | def __init__(self, incoming_packets_buffer: int | float) -> None:  # n...
  function _read_loop (line 665) | def _read_loop(read_fn: Callable[[int], bytes]) -> bytes:
  function handle_client_hello_untrusted (line 676) | async def handle_client_hello_untrusted(
  function dtls_receive_loop (line 744) | async def dtls_receive_loop(
  class DTLSChannelStatistics (line 803) | class DTLSChannelStatistics:
  class DTLSChannel (line 819) | class DTLSChannel(trio.abc.Channel[bytes], metaclass=NoPublicConstructor):
    method __init__ (line 835) | def __init__(
    method _set_replaced (line 859) | def _set_replaced(self) -> None:
    method _check_replaced (line 865) | def _check_replaced(self) -> None:
    method close (line 878) | def close(self) -> None:
    method __enter__ (line 899) | def __enter__(self) -> Self:
    method __exit__ (line 902) | def __exit__(
    method aclose (line 910) | async def aclose(self) -> None:
    method _send_volley (line 920) | async def _send_volley(self, volley_messages: list[_AnyHandshakeMessag...
    method _resend_final_volley (line 929) | async def _resend_final_volley(self) -> None:
    method do_handshake (line 932) | async def do_handshake(self, *, initial_retransmit_timeout: float = 1....
    method send (line 1062) | async def send(self, data: bytes) -> None:
    method receive (line 1079) | async def receive(self) -> bytes:
    method set_ciphertext_mtu (line 1105) | def set_ciphertext_mtu(self, new_mtu: int) -> None:
    method get_cleartext_mtu (line 1140) | def get_cleartext_mtu(self) -> int:
    method statistics (line 1151) | def statistics(self) -> DTLSChannelStatistics:
  class DTLSEndpoint (line 1157) | class DTLSEndpoint:
    method __init__ (line 1181) | def __init__(
    method _ensure_receive_loop (line 1216) | def _ensure_receive_loop(self) -> None:
    method __del__ (line 1228) | def __del__(self) -> None:
    method close (line 1245) | def close(self) -> None:
    method __enter__ (line 1257) | def __enter__(self) -> Self:
    method __exit__ (line 1260) | def __exit__(
    method _check_closed (line 1268) | def _check_closed(self) -> None:
    method serve (line 1272) | async def serve(
    method connect (line 1336) | def connect(
  function set_ssl_context_options (line 1372) | def set_ssl_context_options(ctx: SSL.Context) -> None:

FILE: src/trio/_file_io.py
  class _HasClosed (line 104) | class _HasClosed(Protocol):
    method closed (line 106) | def closed(self) -> bool: ...
  class _HasEncoding (line 108) | class _HasEncoding(Protocol):
    method encoding (line 110) | def encoding(self) -> str: ...
  class _HasErrors (line 112) | class _HasErrors(Protocol):
    method errors (line 114) | def errors(self) -> str | None: ...
  class _HasFileNo (line 116) | class _HasFileNo(Protocol):
    method fileno (line 117) | def fileno(self) -> int: ...
  class _HasIsATTY (line 119) | class _HasIsATTY(Protocol):
    method isatty (line 120) | def isatty(self) -> bool: ...
  class _HasNewlines (line 122) | class _HasNewlines(Protocol[T_co]):
    method newlines (line 125) | def newlines(self) -> T_co: ...
  class _HasReadable (line 127) | class _HasReadable(Protocol):
    method readable (line 128) | def readable(self) -> bool: ...
  class _HasSeekable (line 130) | class _HasSeekable(Protocol):
    method seekable (line 131) | def seekable(self) -> bool: ...
  class _HasWritable (line 133) | class _HasWritable(Protocol):
    method writable (line 134) | def writable(self) -> bool: ...
  class _HasBuffer (line 136) | class _HasBuffer(Protocol):
    method buffer (line 138) | def buffer(self) -> BinaryIO: ...
  class _HasRaw (line 140) | class _HasRaw(Protocol):
    method raw (line 142) | def raw(self) -> io.RawIOBase: ...
  class _HasLineBuffering (line 144) | class _HasLineBuffering(Protocol):
    method line_buffering (line 146) | def line_buffering(self) -> bool: ...
  class _HasCloseFD (line 148) | class _HasCloseFD(Protocol):
    method closefd (line 150) | def closefd(self) -> bool: ...
  class _HasName (line 152) | class _HasName(Protocol):
    method name (line 154) | def name(self) -> str: ...
  class _HasMode (line 156) | class _HasMode(Protocol):
    method mode (line 158) | def mode(self) -> str: ...
  class _CanGetValue (line 160) | class _CanGetValue(Protocol[AnyStr_co]):
    method getvalue (line 161) | def getvalue(self) -> AnyStr_co: ...
  class _CanGetBuffer (line 163) | class _CanGetBuffer(Protocol):
    method getbuffer (line 164) | def getbuffer(self) -> memoryview: ...
  class _CanFlush (line 166) | class _CanFlush(Protocol):
    method flush (line 167) | def flush(self) -> None: ...
  class _CanRead (line 169) | class _CanRead(Protocol[AnyStr_co]):
    method read (line 170) | def read(self, size: int | None = ..., /) -> AnyStr_co: ...
  class _CanRead1 (line 172) | class _CanRead1(Protocol):
    method read1 (line 173) | def read1(self, size: int | None = ..., /) -> bytes: ...
  class _CanReadAll (line 175) | class _CanReadAll(Protocol[AnyStr_co]):
    method readall (line 176) | def readall(self) -> AnyStr_co: ...
  class _CanReadInto (line 178) | class _CanReadInto(Protocol):
    method readinto (line 179) | def readinto(self, buf: Buffer, /) -> int | None: ...
  class _CanReadInto1 (line 181) | class _CanReadInto1(Protocol):
    method readinto1 (line 182) | def readinto1(self, buffer: Buffer, /) -> int: ...
  class _CanReadLine (line 184) | class _CanReadLine(Protocol[AnyStr_co]):
    method readline (line 185) | def readline(self, size: int = ..., /) -> AnyStr_co: ...
  class _CanReadLines (line 187) | class _CanReadLines(Protocol[AnyStr]):
    method readlines (line 188) | def readlines(self, hint: int = ..., /) -> list[AnyStr]: ...
  class _CanSeek (line 190) | class _CanSeek(Protocol):
    method seek (line 191) | def seek(self, target: int, whence: int = 0, /) -> int: ...
  class _CanTell (line 193) | class _CanTell(Protocol):
    method tell (line 194) | def tell(self) -> int: ...
  class _CanTruncate (line 196) | class _CanTruncate(Protocol):
    method truncate (line 197) | def truncate(self, size: int | None = ..., /) -> int: ...
  class _CanWrite (line 199) | class _CanWrite(Protocol[T_contra]):
    method write (line 200) | def write(self, data: T_contra, /) -> int: ...
  class _CanWriteLines (line 202) | class _CanWriteLines(Protocol[T_contra]):
    method writelines (line 204) | def writelines(self, lines: Iterable[T_contra], /) -> None: ...
  class _CanPeek (line 206) | class _CanPeek(Protocol[AnyStr_co]):
    method peek (line 207) | def peek(self, size: int = 0, /) -> AnyStr_co: ...
  class _CanDetach (line 209) | class _CanDetach(Protocol[T_co]):
    method detach (line 211) | def detach(self) -> T_co: ...
  class _CanClose (line 213) | class _CanClose(Protocol):
    method close (line 214) | def close(self) -> None: ...
  class AsyncIOWrapper (line 219) | class AsyncIOWrapper(AsyncResource, Generic[FileT_co]):
    method __init__ (line 228) | def __init__(self, file: FileT_co) -> None:
    method wrapped (line 232) | def wrapped(self) -> FileT_co:
    method __getattr__ (line 239) | def __getattr__(self, name: str) -> object:
    method __dir__ (line 259) | def __dir__(self) -> Iterable[str]:
    method __aiter__ (line 265) | def __aiter__(self) -> AsyncIOWrapper[FileT_co]:
    method __anext__ (line 268) | async def __anext__(self: AsyncIOWrapper[_CanReadLine[AnyStr]]) -> Any...
    method detach (line 275) | async def detach(self: AsyncIOWrapper[_CanDetach[T]]) -> AsyncIOWrappe...
    method aclose (line 286) | async def aclose(self: AsyncIOWrapper[_CanClose]) -> None:
    method closed (line 304) | def closed(self: AsyncIOWrapper[_HasClosed]) -> bool: ...
    method encoding (line 306) | def encoding(self: AsyncIOWrapper[_HasEncoding]) -> str: ...
    method errors (line 308) | def errors(self: AsyncIOWrapper[_HasErrors]) -> str | None: ...
    method newlines (line 310) | def newlines(self: AsyncIOWrapper[_HasNewlines[T]]) -> T: ...
    method buffer (line 312) | def buffer(self: AsyncIOWrapper[_HasBuffer]) -> BinaryIO: ...
    method raw (line 314) | def raw(self: AsyncIOWrapper[_HasRaw]) -> io.RawIOBase: ...
    method line_buffering (line 316) | def line_buffering(self: AsyncIOWrapper[_HasLineBuffering]) -> int: ...
    method closefd (line 318) | def closefd(self: AsyncIOWrapper[_HasCloseFD]) -> bool: ...
    method name (line 320) | def name(self: AsyncIOWrapper[_HasName]) -> str: ...
    method mode (line 322) | def mode(self: AsyncIOWrapper[_HasMode]) -> str: ...
    method fileno (line 324) | def fileno(self: AsyncIOWrapper[_HasFileNo]) -> int: ...
    method isatty (line 325) | def isatty(self: AsyncIOWrapper[_HasIsATTY]) -> bool: ...
    method readable (line 326) | def readable(self: AsyncIOWrapper[_HasReadable]) -> bool: ...
    method seekable (line 327) | def seekable(self: AsyncIOWrapper[_HasSeekable]) -> bool: ...
    method writable (line 328) | def writable(self: AsyncIOWrapper[_HasWritable]) -> bool: ...
    method getvalue (line 329) | def getvalue(self: AsyncIOWrapper[_CanGetValue[AnyStr]]) -> AnyStr: ...
    method getbuffer (line 330) | def getbuffer(self: AsyncIOWrapper[_CanGetBuffer]) -> memoryview: ...
    method flush (line 331) | async def flush(self: AsyncIOWrapper[_CanFlush]) -> None: ...
    method read (line 332) | async def read(self: AsyncIOWrapper[_CanRead[AnyStr]], size: int | Non...
    method read1 (line 333) | async def read1(self: AsyncIOWrapper[_CanRead1], size: int | None = -1...
    method readall (line 334) | async def readall(self: AsyncIOWrapper[_CanReadAll[AnyStr]]) -> AnyStr...
    method readinto (line 335) | async def readinto(self: AsyncIOWrapper[_CanReadInto], buf: Buffer, /)...
    method readline (line 336) | async def readline(self: AsyncIOWrapper[_CanReadLine[AnyStr]], size: i...
    method readlines (line 337) | async def readlines(self: AsyncIOWrapper[_CanReadLines[AnyStr]]) -> li...
    method seek (line 338) | async def seek(self: AsyncIOWrapper[_CanSeek], target: int, whence: in...
    method tell (line 339) | async def tell(self: AsyncIOWrapper[_CanTell]) -> int: ...
    method truncate (line 340) | async def truncate(self: AsyncIOWrapper[_CanTruncate], size: int | Non...
    method write (line 341) | async def write(self: AsyncIOWrapper[_CanWrite[T]], data: T, /) -> int...
    method writelines (line 342) | async def writelines(self: AsyncIOWrapper[_CanWriteLines[T]], lines: I...
    method readinto1 (line 343) | async def readinto1(self: AsyncIOWrapper[_CanReadInto1], buffer: Buffe...
    method peek (line 344) | async def peek(self: AsyncIOWrapper[_CanPeek[AnyStr]], size: int = 0, ...
  function open_file (line 353) | async def open_file(
  function open_file (line 366) | async def open_file(
  function open_file (line 379) | async def open_file(
  function open_file (line 392) | async def open_file(
  function open_file (line 405) | async def open_file(
  function open_file (line 418) | async def open_file(
  function open_file (line 431) | async def open_file(  # type: ignore[explicit-any]  # Any usage matches ...
  function open_file (line 443) | async def open_file(
  function wrap_file (line 486) | def wrap_file(file: FileT) -> AsyncIOWrapper[FileT]:

FILE: src/trio/_highlevel_generic.py
  function aclose_forcefully (line 16) | async def aclose_forcefully(resource: AsyncResource) -> None:
  function _is_halfclosable (line 46) | def _is_halfclosable(stream: SendStream) -> TypeGuard[HalfCloseableStream]:
  class StapledStream (line 53) | class StapledStream(
    method send_all (line 94) | async def send_all(self, data: bytes | bytearray | memoryview) -> None:
    method wait_send_all_might_not_block (line 98) | async def wait_send_all_might_not_block(self) -> None:
    method send_eof (line 102) | async def send_eof(self) -> None:
    method receive_some (line 116) | async def receive_some(self, max_bytes: int | None = None) -> bytes:
    method aclose (line 120) | async def aclose(self) -> None:

FILE: src/trio/_highlevel_open_tcp_listeners.py
  function _compute_backlog (line 46) | def _compute_backlog(backlog: int | None) -> int:
  function open_tcp_listeners (line 57) | async def open_tcp_listeners(
  function serve_tcp (line 172) | async def serve_tcp(

FILE: src/trio/_highlevel_open_tcp_stream.py
  function close_all (line 120) | def close_all() -> Generator[set[SocketType], None, None]:
  function reorder_for_rfc_6555_section_5_4 (line 137) | def reorder_for_rfc_6555_section_5_4(  # type: ignore[explicit-any]
  function format_host_port (line 157) | def format_host_port(host: str | bytes, port: int | str) -> str:
  function open_tcp_stream (line 185) | async def open_tcp_stream(

FILE: src/trio/_highlevel_open_unix_stream.py
  class Closable (line 14) | class Closable(Protocol):
    method close (line 15) | def close(self) -> None: ...
  function close_on_error (line 30) | def close_on_error(obj: CloseT) -> Generator[CloseT, None, None]:
  function open_unix_socket (line 38) | async def open_unix_socket(

FILE: src/trio/_highlevel_serve_listeners.py
  function _run_handler (line 32) | async def _run_handler(stream: StreamT, handler: Handler[StreamT]) -> None:
  function _serve_one_listener (line 39) | async def _serve_one_listener(
  function serve_listeners (line 70) | async def serve_listeners(  # type: ignore[explicit-any]

FILE: src/trio/_highlevel_socket.py
  function _translate_socket_errors_to_stream_errors (line 44) | def _translate_socket_errors_to_stream_errors() -> Generator[None, None,...
  class SocketStream (line 55) | class SocketStream(HalfCloseableStream):
    method __init__ (line 79) | def __init__(self, socket: SocketType) -> None:
    method send_all (line 109) | async def send_all(self, data: bytes | bytearray | memoryview) -> None:
    method wait_send_all_might_not_block (line 126) | async def wait_send_all_might_not_block(self) -> None:
    method send_eof (line 133) | async def send_eof(self) -> None:
    method receive_some (line 143) | async def receive_some(self, max_bytes: int | None = None) -> bytes:
    method aclose (line 151) | async def aclose(self) -> None:
    method setsockopt (line 158) | def setsockopt(self, level: int, option: int, value: int | Buffer) -> ...
    method setsockopt (line 161) | def setsockopt(self, level: int, option: int, value: None, length: int...
    method setsockopt (line 164) | def setsockopt(
    method getsockopt (line 189) | def getsockopt(self, level: int, option: int) -> int: ...
    method getsockopt (line 192) | def getsockopt(self, level: int, option: int, buffersize: int) -> byte...
    method getsockopt (line 194) | def getsockopt(self, level: int, option: int, buffersize: int = 0) -> ...
  class SocketListener (line 359) | class SocketListener(Listener[SocketStream]):
    method __init__ (line 376) | def __init__(self, socket: SocketType) -> None:
    method accept (line 392) | async def accept(self) -> SocketStream:
    method aclose (line 420) | async def aclose(self) -> None:

FILE: src/trio/_highlevel_ssl_helpers.py
  function open_ssl_over_tcp_stream (line 27) | async def open_ssl_over_tcp_stream(
  function open_ssl_over_tcp_listeners (line 80) | async def open_ssl_over_tcp_listeners(
  function serve_ssl_over_tcp (line 108) | async def serve_ssl_over_tcp(

FILE: src/trio/_path.py
  function _wraps_async (line 43) | def _wraps_async(  # type: ignore[explicit-any]
  function _wrap_method (line 72) | def _wrap_method(
  function _wrap_method_path (line 82) | def _wrap_method_path(
  function _wrap_method_path_iterable (line 92) | def _wrap_method_path_iterable(
  class Path (line 119) | class Path(pathlib.PurePath):
    method __new__ (line 130) | def __new__(cls, *args: str | os.PathLike[str]) -> Self:
    method cwd (line 137) | def cwd(cls) -> Self:
    method home (line 142) | def home(cls) -> Self:
    method open (line 146) | async def open(
    method open (line 156) | async def open(
    method open (line 166) | async def open(
    method open (line 176) | async def open(
    method open (line 186) | async def open(
    method open (line 196) | async def open(
    method open (line 206) | async def open(  # type: ignore[explicit-any]  # Any usage matches bui...
    method open (line 216) | def open(self, *args: Any, **kwargs: Any) -> AsyncIOWrapper[IO[Any]]: ...
    method __repr__ (line 219) | def __repr__(self) -> str:
    method as_uri (line 266) | def as_uri(self) -> str:
  class PosixPath (line 275) | class PosixPath(Path, pathlib.PurePosixPath):
  class WindowsPath (line 284) | class WindowsPath(Path, pathlib.PureWindowsPath):

FILE: src/trio/_repl.py
  class SuppressDecorator (line 22) | class SuppressDecorator(contextlib.ContextDecorator, contextlib.suppress):
  function terminal_newline (line 28) | def terminal_newline() -> None:  # TODO: test this line
  class TrioInteractiveConsole (line 40) | class TrioInteractiveConsole(InteractiveConsole):
    method __init__ (line 41) | def __init__(self, repl_locals: dict[str, object] | None = None) -> None:
    method runcode (line 47) | def runcode(self, code: CodeType) -> None:
    method raw_input (line 80) | def raw_input(self, prompt: str = "") -> str:
    method raw_input (line 90) | def raw_input(self, prompt: str = "") -> str:
    method write (line 116) | def write(self, output: str) -> None:
  function run_repl (line 125) | async def run_repl(console: TrioInteractiveConsole) -> None:
  function main (line 143) | def main(original_locals: dict[str, object]) -> None:

FILE: src/trio/_signals.py
  function _signal_handler (line 55) | def _signal_handler(
  class SignalReceiver (line 69) | class SignalReceiver:
    method __init__ (line 70) | def __init__(self) -> None:
    method _add (line 79) | def _add(self, signum: int) -> None:
    method _redeliver_remaining (line 86) | def _redeliver_remaining(self) -> None:
    method __aiter__ (line 104) | def __aiter__(self) -> Self:
    method __anext__ (line 107) | async def __anext__(self) -> int:
  function get_pending_signal_count (line 122) | def get_pending_signal_count(rec: AsyncIterator[int]) -> int:
  function open_signal_receiver (line 130) | def open_signal_receiver(

FILE: src/trio/_socket.py
  class _try_sync (line 61) | class _try_sync:
    method __init__ (line 62) | def __init__(
    method _is_blocking_io_error (line 68) | def _is_blocking_io_error(self, exc: BaseException) -> bool:
    method __aenter__ (line 74) | async def __aenter__(self) -> None:
    method __aexit__ (line 77) | async def __aexit__(
  function set_custom_hostname_resolver (line 101) | def set_custom_hostname_resolver(
  function set_custom_socket_factory (line 135) | def set_custom_socket_factory(
  function getaddrinfo (line 175) | async def getaddrinfo(
  function getnameinfo (line 258) | async def getnameinfo(
  function getprotobyname (line 283) | async def getprotobyname(name: str) -> int:
  function from_stdlib_socket (line 304) | def from_stdlib_socket(sock: _stdlib_socket.socket) -> SocketType:
  function fromfd (line 313) | def fromfd(
  function fromshare (line 329) | def fromshare(info: bytes) -> SocketType:
  function socketpair (line 345) | def socketpair(
  function socket (line 359) | def socket(
  function _sniff_sockopts_for_fileno (line 386) | def _sniff_sockopts_for_fileno(
  function _make_simple_sock_method_wrapper (line 433) | def _make_simple_sock_method_wrapper(
  function _resolve_address_nocp (line 472) | async def _resolve_address_nocp(
  class SocketType (line 546) | class SocketType:
    method __init__ (line 547) | def __init__(self) -> None:
    method detach (line 557) | def detach(self) -> int:
    method fileno (line 560) | def fileno(self) -> int:
    method getpeername (line 563) | def getpeername(self) -> AddressFormat:
    method getsockname (line 566) | def getsockname(self) -> AddressFormat:
    method getsockopt (line 570) | def getsockopt(self, level: int, optname: int) -> int: ...
    method getsockopt (line 573) | def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
    method getsockopt (line 575) | def getsockopt(
    method setsockopt (line 584) | def setsockopt(self, level: int, optname: int, value: int | Buffer) ->...
    method setsockopt (line 587) | def setsockopt(
    method setsockopt (line 595) | def setsockopt(
    method listen (line 604) | def listen(self, backlog: int = min(_stdlib_socket.SOMAXCONN, 128)) ->...
    method get_inheritable (line 607) | def get_inheritable(self) -> bool:
    method set_inheritable (line 610) | def set_inheritable(self, inheritable: bool) -> None:
    method share (line 617) | def share(self, process_id: int) -> bytes:
    method __enter__ (line 620) | def __enter__(self) -> Self:
    method __exit__ (line 623) | def __exit__(
    method family (line 632) | def family(self) -> AddressFamily:
    method type (line 636) | def type(self) -> SocketKind:
    method proto (line 640) | def proto(self) -> int:
    method did_shutdown_SHUT_WR (line 644) | def did_shutdown_SHUT_WR(self) -> bool:
    method __repr__ (line 648) | def __repr__(self) -> str:
    method dup (line 651) | def dup(self) -> SocketType:
    method close (line 654) | def close(self) -> None:
    method bind (line 657) | async def bind(self, address: AddressFormat) -> None:
    method shutdown (line 660) | def shutdown(self, flag: int) -> None:
    method is_readable (line 663) | def is_readable(self) -> bool:
    method wait_writable (line 667) | async def wait_writable(self) -> None:
    method accept (line 671) | async def accept(self) -> tuple[SocketType, AddressFormat]:
    method connect (line 674) | async def connect(self, address: AddressFormat) -> None:
    method recv (line 677) | def recv(self, buflen: int, flags: int = 0, /) -> Awaitable[bytes]:
    method recv_into (line 680) | def recv_into(
    method recvfrom (line 689) | def recvfrom(
    method recvfrom_into (line 698) | def recvfrom_into(
    method recvmsg (line 710) | def recvmsg(
    method recvmsg_into (line 723) | def recvmsg_into(
    method send (line 732) | def send(self, bytes: Buffer, flags: int = 0, /) -> Awaitable[int]:
    method sendto (line 736) | async def sendto(
    method sendto (line 744) | async def sendto(
    method sendto (line 752) | async def sendto(self, *args: object) -> int:
    method sendmsg (line 760) | async def sendmsg(
  class _SocketType (line 786) | class _SocketType(SocketType):
    method __init__ (line 787) | def __init__(self, sock: _stdlib_socket.socket) -> None:
    method detach (line 803) | def detach(self) -> int:
    method fileno (line 806) | def fileno(self) -> int:
    method getpeername (line 809) | def getpeername(self) -> AddressFormat:
    method getsockname (line 812) | def getsockname(self) -> AddressFormat:
    method getsockopt (line 816) | def getsockopt(self, level: int, optname: int) -> int: ...
    method getsockopt (line 819) | def getsockopt(self, level: int, optname: int, buflen: int) -> bytes: ...
    method getsockopt (line 821) | def getsockopt(
    method setsockopt (line 832) | def setsockopt(self, level: int, optname: int, value: int | Buffer) ->...
    method setsockopt (line 835) | def setsockopt(
    method setsockopt (line 843) | def setsockopt(
    method listen (line 865) | def listen(self, backlog: int = min(_stdlib_socket.SOMAXCONN, 128)) ->...
    method get_inheritable (line 868) | def get_inheritable(self) -> bool:
    method set_inheritable (line 871) | def set_inheritable(self, inheritable: bool) -> None:
    method share (line 878) | def share(self, process_id: int) -> bytes:
    method __enter__ (line 881) | def __enter__(self) -> Self:
    method __exit__ (line 884) | def __exit__(
    method family (line 893) | def family(self) -> AddressFamily:
    method type (line 897) | def type(self) -> SocketKind:
    method proto (line 901) | def proto(self) -> int:
    method did_shutdown_SHUT_WR (line 905) | def did_shutdown_SHUT_WR(self) -> bool:
    method __repr__ (line 908) | def __repr__(self) -> str:
    method dup (line 911) | def dup(self) -> SocketType:
    method close (line 915) | def close(self) -> None:
    method bind (line 920) | async def bind(self, address: AddressFormat) -> None:
    method shutdown (line 938) | def shutdown(self, flag: int) -> None:
    method is_readable (line 945) | def is_readable(self) -> bool:
    method wait_writable (line 954) | async def wait_writable(self) -> None:
    method _resolve_address_nocp (line 957) | async def _resolve_address_nocp(
    method _nonblocking_helper (line 985) | async def _nonblocking_helper(
    method accept (line 1032) | async def accept(self) -> tuple[SocketType, AddressFormat]:
    method connect (line 1041) | async def connect(self, address: AddressFormat) -> None:
    method recv (line 1121) | def recv(self, buflen: int, flags: int = 0, /) -> Awaitable[bytes]: ...
    method recv_into (line 1134) | def recv_into(
    method recvfrom (line 1153) | def recvfrom(
    method recvfrom_into (line 1171) | def recvfrom_into(
    method recvmsg (line 1193) | def recvmsg(
    method recvmsg_into (line 1216) | def recvmsg_into(
    method send (line 1236) | def send(self, bytes: Buffer, flags: int = 0, /) -> Awaitable[int]: ...
    method sendto (line 1248) | async def sendto(
    method sendto (line 1256) | async def sendto(
    method sendto (line 1265) | async def sendto(self, *args: object) -> int:
    method sendmsg (line 1288) | async def sendmsg(

FILE: src/trio/_ssl.py
  function _is_eof (line 207) | def _is_eof(exc: BaseException | None) -> bool:
  class NeedHandshakeError (line 217) | class NeedHandshakeError(Exception):
  class _Once (line 225) | class _Once:
    method __init__ (line 228) | def __init__(
    method ensure (line 238) | async def ensure(self, *, checkpoint: bool) -> None:
    method done (line 249) | def done(self) -> bool:
  class SSLStream (line 260) | class SSLStream(Stream, Generic[T_Stream]):
    method __init__ (line 356) | def __init__(
    method __getattr__ (line 426) | def __getattr__(  # type: ignore[explicit-any]
    method __setattr__ (line 438) | def __setattr__(self, name: str, value: object) -> None:
    method __dir__ (line 444) | def __dir__(self) -> list[str]:
    method _check_status (line 447) | def _check_status(self) -> None:
    method _retry (line 461) | async def _retry(
    method _do_handshake (line 640) | async def _do_handshake(self) -> None:
    method do_handshake (line 647) | async def do_handshake(self) -> None:
    method receive_some (line 682) | async def receive_some(self, max_bytes: int | None = None) -> bytes | ...
    method send_all (line 737) | async def send_all(self, data: bytes | bytearray | memoryview) -> None:
    method unwrap (line 758) | async def unwrap(self) -> tuple[Stream, bytes | bytearray]:
    method aclose (line 784) | async def aclose(self) -> None:
    method wait_send_all_might_not_block (line 869) | async def wait_send_all_might_not_block(self) -> None:
  class SSLListener (line 915) | class SSLListener(Listener[SSLStream[T_Stream]]):
    method __init__ (line 937) | def __init__(
    method accept (line 948) | async def accept(self) -> SSLStream[T_Stream]:
    method aclose (line 962) | async def aclose(self) -> None:

FILE: src/trio/_subprocess.py
  function pidfd_open (line 51) | def pidfd_open(fd: int, flags: int) -> int: ...
  function pidfd_open (line 87) | def pidfd_open(fd: int, flags: int) -> int:
  class HasFileno (line 98) | class HasFileno(Protocol):
    method fileno (line 101) | def fileno(self) -> int: ...
  class Process (line 105) | class Process(metaclass=NoPublicConstructor):
    method __init__ (line 158) | def __init__(
    method __repr__ (line 195) | def __repr__(self) -> str:
    method returncode (line 207) | def returncode(self) -> int | None:
    method _close_pidfd (line 228) | def _close_pidfd(self) -> None:
    method wait (line 234) | async def wait(self) -> int:
    method poll (line 260) | def poll(self) -> int | None:
    method send_signal (line 272) | def send_signal(self, sig: signal.Signals | int) -> None:
    method terminate (line 282) | def terminate(self) -> None:
    method kill (line 293) | def kill(self) -> None:
  function _open_process (line 306) | async def _open_process(
  function _windows_deliver_cancel (line 434) | async def _windows_deliver_cancel(p: Process) -> None:  # noqa: RUF029
  function _posix_deliver_cancel (line 444) | async def _posix_deliver_cancel(p: Process) -> None:
  function _run_process (line 466) | async def _run_process(
  class GeneralProcessArgs (line 803) | class GeneralProcessArgs(TypedDict, total=False):
  class WindowsProcessArgs (line 817) | class WindowsProcessArgs(GeneralProcessArgs, total=False):
  function open_process (line 824) | async def open_process(
  function run_process (line 882) | async def run_process(
  class UnixProcessArgs3_10 (line 1091) | class UnixProcessArgs3_10(GeneralProcessArgs, total=False):
  class UnixProcessArgs3_11 (line 1108) | class UnixProcessArgs3_11(UnixProcessArgs3_10, total=False):
  class UnixRunProcessMixin (line 1113) | class UnixRunProcessMixin(TypedDict, total=False):
  class UnixRunProcessArgs (line 1127) | class UnixRunProcessArgs(UnixProcessArgs3_11, UnixRunProcessMixin):
  class UnixRunProcessArgs (line 1133) | class UnixRunProcessArgs(UnixProcessArgs3_10, UnixRunProcessMixin):
  function open_process (line 1137) | async def open_process(
  function open_process (line 1146) | async def open_process(
  function run_process (line 1155) | async def run_process(
  function run_process (line 1164) | async def run_process(

FILE: src/trio/_subprocess_platform/__init__.py
  class ClosableSendStream (line 19) | class ClosableSendStream(SendStream):
    method close (line 20) | def close(self) -> None: ...
  class ClosableReceiveStream (line 22) | class ClosableReceiveStream(ReceiveStream):
    method close (line 23) | def close(self) -> None: ...
  function wait_child_exiting (line 28) | async def wait_child_exiting(process: _subprocess.Process) -> None:
  function create_pipe_to_child_stdin (line 43) | def create_pipe_to_child_stdin() -> tuple[ClosableSendStream, int]:
  function create_pipe_from_child_output (line 56) | def create_pipe_from_child_output() -> tuple[ClosableReceiveStream, int]:
  function create_pipe_to_child_stdin (line 88) | def create_pipe_to_child_stdin() -> tuple[trio.lowlevel.FdStream, int]:
  function create_pipe_from_child_output (line 92) | def create_pipe_from_child_output() -> tuple[trio.lowlevel.FdStream, int]:
  function create_pipe_to_child_stdin (line 109) | def create_pipe_to_child_stdin() -> tuple[PipeSendStream, int]:
  function create_pipe_from_child_output (line 114) | def create_pipe_from_child_output() -> tuple[PipeReceiveStream, int]:

FILE: src/trio/_subprocess_platform/kqueue.py
  function wait_child_exiting (line 12) | async def wait_child_exiting(process: _subprocess.Process) -> None:

FILE: src/trio/_subprocess_platform/waitid.py
  function sync_wait_reapable (line 16) | def sync_wait_reapable(pid: int) -> None:
  function sync_wait_reapable (line 47) | def sync_wait_reapable(pid: int) -> None:
  function _waitid_system_task (line 71) | async def _waitid_system_task(pid: int, event: Event) -> None:
  function wait_child_exiting (line 98) | async def wait_child_exiting(process: "_subprocess.Process") -> None:

FILE: src/trio/_subprocess_platform/windows.py
  function wait_child_exiting (line 9) | async def wait_child_exiting(process: "_subprocess.Process") -> None:

FILE: src/trio/_sync.py
  function deprecated (line 33) | def deprecated(
  class EventStatistics (line 47) | class EventStatistics:
  class Event (line 62) | class Event:
    method is_set (line 91) | def is_set(self) -> bool:
    method set (line 96) | def set(self) -> None:
    method wait (line 104) | async def wait(self) -> None:
    method statistics (line 122) | def statistics(self) -> EventStatistics:
    method __bool__ (line 137) | def __bool__(self) -> Literal[True]:
  class _HasAcquireRelease (line 148) | class _HasAcquireRelease(Protocol):
    method acquire (line 151) | async def acquire(self) -> object: ...
    method release (line 153) | def release(self) -> object: ...
  class AsyncContextManagerMixin (line 156) | class AsyncContextManagerMixin:
    method __aenter__ (line 158) | async def __aenter__(self: _HasAcquireRelease) -> None:
    method __aexit__ (line 162) | async def __aexit__(
  class CapacityLimiterStatistics (line 172) | class CapacityLimiterStatistics:
  class CapacityLimiter (line 200) | class CapacityLimiter(AsyncContextManagerMixin):
    method __init__ (line 255) | def __init__(self, total_tokens: int | float) -> None:  # noqa: PYI041
    method __repr__ (line 264) | def __repr__(self) -> str:
    method total_tokens (line 268) | def total_tokens(self) -> int | float:
    method total_tokens (line 283) | def total_tokens(self, new_total_tokens: int | float) -> None:  # noqa...
    method _wake_waiters (line 291) | def _wake_waiters(self) -> None:
    method borrowed_tokens (line 297) | def borrowed_tokens(self) -> int:
    method available_tokens (line 302) | def available_tokens(self) -> int | float:
    method acquire_nowait (line 307) | def acquire_nowait(self) -> None:
    method acquire_on_behalf_of_nowait (line 319) | def acquire_on_behalf_of_nowait(self, borrower: Task | object) -> None:
    method acquire (line 347) | async def acquire(self) -> None:
    method acquire_on_behalf_of (line 358) | async def acquire_on_behalf_of(self, borrower: Task | object) -> None:
    method release (line 387) | def release(self) -> None:
    method release_on_behalf_of (line 398) | def release_on_behalf_of(self, borrower: Task | object) -> None:
    method statistics (line 413) | def statistics(self) -> CapacityLimiterStatistics:
  class Semaphore (line 441) | class Semaphore(AsyncContextManagerMixin):
    method __init__ (line 468) | def __init__(self, initial_value: int, *, max_value: int | None = None...
    method __repr__ (line 486) | def __repr__(self) -> str:
    method value (line 494) | def value(self) -> int:
    method max_value (line 499) | def max_value(self) -> int | None:
    method acquire_nowait (line 504) | def acquire_nowait(self) -> None:
    method acquire (line 518) | async def acquire(self) -> None:
    method release (line 532) | def release(self) -> None:
    method statistics (line 549) | def statistics(self) -> ParkingLotStatistics:
  class LockStatistics (line 562) | class LockStatistics:
  class _LockImpl (line 581) | class _LockImpl(AsyncContextManagerMixin):
    method __repr__ (line 585) | def __repr__(self) -> str:
    method locked (line 594) | def locked(self) -> bool:
    method acquire_nowait (line 604) | def acquire_nowait(self) -> None:
    method acquire (line 623) | async def acquire(self) -> None:
    method release (line 646) | def release(self) -> None:
    method statistics (line 663) | def statistics(self) -> LockStatistics:
  class Lock (line 683) | class Lock(_LockImpl):
  class StrictFIFOLock (line 698) | class StrictFIFOLock(_LockImpl):
  class ConditionStatistics (line 762) | class ConditionStatistics:
  class Condition (line 779) | class Condition(AsyncContextManagerMixin):
    method __init__ (line 794) | def __init__(self, lock: Lock | None = None) -> None:
    method locked (line 802) | def locked(self) -> bool:
    method acquire_nowait (line 811) | def acquire_nowait(self) -> None:
    method acquire (line 820) | async def acquire(self) -> None:
    method release (line 828) | def release(self) -> None:
    method wait (line 833) | async def wait(self) -> None:
    method notify (line 869) | def notify(self, n: int = 1) -> None:
    method notify_all (line 883) | def notify_all(self) -> None:
    method statistics (line 894) | def statistics(self) -> ConditionStatistics:

FILE: src/trio/_tests/check_type_completeness.py
  function run_pyright (line 30) | def run_pyright(platform: str) -> subprocess.CompletedProcess[bytes]:
  function has_docstring_at_runtime (line 45) | def has_docstring_at_runtime(name: str) -> bool:
  function check_type (line 114) | def check_type(
  function main (line 172) | def main(args: argparse.Namespace) -> int:

FILE: src/trio/_tests/pytest_plugin.py
  function pytest_addoption (line 14) | def pytest_addoption(parser: pytest.Parser) -> None:
  function pytest_configure (line 23) | def pytest_configure(config: pytest.Config) -> None:
  function mock_clock (line 31) | def mock_clock() -> MockClock:
  function autojump_clock (line 36) | def autojump_clock() -> MockClock:
  function pytest_pyfunc_call (line 45) | def pytest_pyfunc_call(pyfuncitem: pytest.Function) -> None:
  function skip_if_optional_else_raise (line 50) | def skip_if_optional_else_raise(error: ImportError) -> NoReturn:

FILE: src/trio/_tests/test_abc.py
  function test_instrument_implements_hook_methods (line 10) | def test_instrument_implements_hook_methods() -> None:
  function test_AsyncResource_defaults (line 32) | async def test_AsyncResource_defaults() -> None:
  function test_abc_generics (line 47) | def test_abc_generics() -> None:

FILE: src/trio/_tests/test_channel.py
  function test_channel (line 20) | async def test_channel() -> None:
  function test_553 (line 63) | async def test_553(autojump_clock: trio.abc.Clock) -> None:
  function test_channel_multiple_producers (line 71) | async def test_channel_multiple_producers() -> None:
  function test_channel_multiple_consumers (line 92) | async def test_channel_multiple_consumers() -> None:
  function test_close_basics (line 115) | async def test_close_basics() -> None:
  function test_close_sync (line 173) | async def test_close_sync() -> None:
  function test_receive_channel_clone_and_close (line 231) | async def test_receive_channel_clone_and_close() -> None:
  function test_close_multiple_send_handles (line 258) | async def test_close_multiple_send_handles() -> None:
  function test_close_multiple_receive_handles (line 279) | async def test_close_multiple_receive_handles() -> None:
  function test_inf_capacity (line 300) | async def test_inf_capacity() -> None:
  function test_statistics (line 312) | async def test_statistics() -> None:
  function test_channel_fairness (line 362) | async def test_channel_fairness() -> None:
  function test_unbuffered (line 404) | async def test_unbuffered() -> None:
  function test_as_safe_channel_exhaust (line 423) | async def test_as_safe_channel_exhaust() -> None:
  function test_as_safe_channel_broken_resource (line 433) | async def test_as_safe_channel_broken_resource() -> None:
  function test_as_safe_channel_cancelled (line 452) | async def test_as_safe_channel_cancelled() -> None:
  function test_as_safe_channel_no_race (line 466) | async def test_as_safe_channel_no_race() -> None:
  function test_as_safe_channel_buffer_size_too_small (line 480) | async def test_as_safe_channel_buffer_size_too_small(
  function test_as_safe_channel_no_interleave (line 497) | async def test_as_safe_channel_no_interleave() -> None:
  function test_as_safe_channel_genexit_finally (line 508) | async def test_as_safe_channel_genexit_finally() -> None:
  function test_as_safe_channel_nested_loop (line 539) | async def test_as_safe_channel_nested_loop() -> None:
  function test_as_safe_channel_doesnt_leak_cancellation (line 556) | async def test_as_safe_channel_doesnt_leak_cancellation() -> None:
  function test_as_safe_channel_dont_unwrap_user_exceptiongroup (line 571) | async def test_as_safe_channel_dont_unwrap_user_exceptiongroup() -> None:
  function test_as_safe_channel_multiple_receiver (line 582) | async def test_as_safe_channel_multiple_receiver() -> None:
  function test_as_safe_channel_multi_cancel (line 606) | async def test_as_safe_channel_multi_cancel() -> None:
  function test_as_safe_channel_genexit_exception_group (line 634) | async def test_as_safe_channel_genexit_exception_group() -> None:
  function test_as_safe_channel_does_not_suppress_nested_genexit (line 649) | async def test_as_safe_channel_does_not_suppress_nested_genexit() -> None:
  function test_as_safe_channel_genexit_filter (line 660) | async def test_as_safe_channel_genexit_filter() -> None:
  function test_as_safe_channel_swallowing_extra_exceptions (line 679) | async def test_as_safe_channel_swallowing_extra_exceptions() -> None:
  function test_as_safe_channel_close_between_iteration (line 704) | async def test_as_safe_channel_close_between_iteration() -> None:
  function test_as_safe_channel_close_before_iteration (line 722) | async def test_as_safe_channel_close_before_iteration() -> None:
  function test_as_safe_channel_close_during_iteration (line 734) | async def test_as_safe_channel_close_during_iteration() -> None:

FILE: src/trio/_tests/test_contextvars.py
  function test_contextvars_default (line 12) | async def test_contextvars_default() -> None:
  function test_contextvars_set (line 25) | async def test_contextvars_set() -> None:
  function test_contextvars_copy (line 41) | async def test_contextvars_copy() -> None:

FILE: src/trio/_tests/test_deprecate.py
  function recwarn_always (line 19) | def recwarn_always(recwarn: pytest.WarningsRecorder) -> pytest.WarningsR...
  function _here (line 27) | def _here() -> tuple[str, int]:
  function test_warn_deprecated (line 35) | def test_warn_deprecated(recwarn_always: pytest.WarningsRecorder) -> None:
  function test_warn_deprecated_no_instead_or_issue (line 52) | def test_warn_deprecated_no_instead_or_issue(
  function test_warn_deprecated_stacklevel (line 65) | def test_warn_deprecated_stacklevel(recwarn_always: pytest.WarningsRecor...
  function old (line 79) | def old() -> None:  # pragma: no cover
  function new (line 83) | def new() -> None:  # pragma: no cover
  function test_warn_deprecated_formatting (line 87) | def test_warn_deprecated_formatting(recwarn_always: pytest.WarningsRecor...
  function deprecated_old (line 96) | def deprecated_old() -> int:
  function test_deprecated_decorator (line 100) | def test_deprecated_decorator(recwarn_always: pytest.WarningsRecorder) -...
  class Foo (line 110) | class Foo:
    method method (line 112) | def method(self) -> int:
  function test_deprecated_decorator_method (line 116) | def test_deprecated_decorator_method(recwarn_always: pytest.WarningsReco...
  function deprecated_with_thing (line 125) | def deprecated_with_thing() -> int:
  function test_deprecated_decorator_with_explicit_thing (line 129) | def test_deprecated_decorator_with_explicit_thing(
  function new_hotness (line 138) | def new_hotness() -> str:
  function test_deprecated_alias (line 145) | def test_deprecated_alias(recwarn_always: pytest.WarningsRecorder) -> None:
  class Alias (line 160) | class Alias:
    method new_hotness_method (line 161) | def new_hotness_method(self) -> str:
  function test_deprecated_alias_method (line 172) | def test_deprecated_alias_method(recwarn_always: pytest.WarningsRecorder...
  function docstring_test1 (line 183) | def docstring_test1() -> None:  # pragma: no cover
  function docstring_test2 (line 188) | def docstring_test2() -> None:  # pragma: no cover
  function docstring_test3 (line 193) | def docstring_test3() -> None:  # pragma: no cover
  function docstring_test4 (line 198) | def docstring_test4() -> None:  # pragma: no cover
  function test_deprecated_docstring_munging (line 202) | def test_deprecated_docstring_munging() -> None:
  function test_module_with_deprecations (line 232) | def test_module_with_deprecations(recwarn_always: pytest.WarningsRecorde...
  function test_warning_class (line 259) | def test_warning_class() -> None:

FILE: src/trio/_tests/test_deprecate_strict_exception_groups_false.py
  function test_deprecation_warning_open_nursery (line 8) | async def test_deprecation_warning_open_nursery() -> None:
  function test_deprecation_warning_run (line 22) | def test_deprecation_warning_run() -> None:
  function test_deprecation_warning_start_guest_run (line 48) | def test_deprecation_warning_start_guest_run() -> None:

FILE: src/trio/_tests/test_dtls.py
  function server_ctx (line 35) | def server_ctx() -> SSL.Context:
  function client_ctx_fn (line 41) | def client_ctx_fn() -> SSL.Context:
  function client_ctx (line 48) | def client_ctx() -> SSL.Context:
  function endpoint (line 59) | def endpoint(**kwargs: int | bool) -> DTLSEndpoint:
  function dtls_echo_server (line 67) | async def dtls_echo_server(
  function test_smoke (line 108) | async def test_smoke(
  function test_handshake_over_terrible_network (line 141) | async def test_handshake_over_terrible_network(
  function test_implicit_handshake (line 230) | async def test_implicit_handshake(
  function test_full_duplex (line 242) | async def test_full_duplex(server_ctx: SSL.Context, client_ctx: SSL.Cont...
  function test_channel_closing (line 267) | async def test_channel_closing(
  function test_serve_exits_cleanly_on_close (line 287) | async def test_serve_exits_cleanly_on_close(server_ctx: SSL.Context) -> ...
  function test_client_multiplex (line 298) | async def test_client_multiplex(server_ctx: SSL.Context) -> None:
  function test_dtls_over_dgram_only (line 329) | async def test_dtls_over_dgram_only() -> None:
  function test_double_serve (line 335) | async def test_double_serve(server_ctx: SSL.Context) -> None:
  function test_connect_to_non_server (line 353) | async def test_connect_to_non_server(
  function test_incoming_buffer_overflow (line 368) | async def test_incoming_buffer_overflow(
  function test_server_socket_doesnt_crash_on_garbage (line 391) | async def test_server_socket_doesnt_crash_on_garbage(
  function test_invalid_cookie_rejected (line 505) | async def test_invalid_cookie_rejected(
  function test_client_cancels_handshake_and_starts_new_one (line 549) | async def test_client_cancels_handshake_and_starts_new_one(
  function test_swap_client_server (line 594) | async def test_swap_client_server(server_ctx: SSL.Context) -> None:
  function test_openssl_retransmit_doesnt_break_stuff (line 626) | async def test_openssl_retransmit_doesnt_break_stuff(
  function test_initial_retransmit_timeout_configuration (line 680) | async def test_initial_retransmit_timeout_configuration(
  function test_explicit_tiny_mtu_is_respected (line 708) | async def test_explicit_tiny_mtu_is_respected(
  function test_handshake_handles_minimum_network_mtu (line 736) | async def test_handshake_handles_minimum_network_mtu(
  function test_system_task_cleaned_up_on_gc (line 773) | async def test_system_task_cleaned_up_on_gc(client_ctx: SSL.Context) -> ...
  function test_gc_before_system_task_starts (line 809) | async def test_gc_before_system_task_starts() -> None:
  function test_gc_as_packet_received (line 820) | async def test_gc_as_packet_received() -> None:
  function test_gc_after_trio_exits (line 841) | def test_gc_after_trio_exits() -> None:
  function test_already_closed_socket_doesnt_crash (line 857) | async def test_already_closed_socket_doesnt_crash() -> None:
  function test_socket_closed_while_processing_clienthello (line 866) | async def test_socket_closed_while_processing_clienthello(
  function test_association_replaced_while_handshake_running (line 888) | async def test_association_replaced_while_handshake_running(
  function test_association_replaced_before_handshake_starts (line 916) | async def test_association_replaced_before_handshake_starts(
  function test_send_to_closed_local_port (line 937) | async def test_send_to_closed_local_port(server_ctx: SSL.Context) -> None:

FILE: src/trio/_tests/test_exports.py
  function _ensure_mypy_cache_updated (line 39) | def _ensure_mypy_cache_updated() -> None:
  function test_core_is_properly_reexported (line 64) | def test_core_is_properly_reexported() -> None:
  function class_is_final (line 82) | def class_is_final(cls: type) -> bool:
  function iter_modules (line 93) | def iter_modules(
  function test_static_tool_sees_all_symbols (line 137) | def test_static_tool_sees_all_symbols(tool: str, modname: str, tmp_path:...
  function test_static_tool_sees_class_members (line 261) | def test_static_tool_sees_class_members(
  function test_nopublic_is_final (line 545) | def test_nopublic_is_final() -> None:
  function test_classes_are_final (line 555) | def test_classes_are_final() -> None:
  function test_pyright_recognizes_init_attributes (line 600) | def test_pyright_recognizes_init_attributes() -> None:

FILE: src/trio/_tests/test_fakenet.py
  function fn (line 20) | def fn() -> FakeNet:
  function test_basic_udp (line 26) | async def test_basic_udp() -> None:
  function test_msg_trunc (line 61) | async def test_msg_trunc() -> None:
  function test_recv_methods (line 70) | async def test_recv_methods() -> None:
  function test_nonwindows_functionality (line 143) | async def test_nonwindows_functionality() -> None:
  function test_windows_functionality (line 200) | async def test_windows_functionality() -> None:
  function test_basic_tcp (line 226) | async def test_basic_tcp() -> None:
  function test_not_implemented_functions (line 232) | async def test_not_implemented_functions() -> None:
  function test_getpeername (line 272) | async def test_getpeername() -> None:
  function test_init (line 288) | async def test_init() -> None:

FILE: src/trio/_tests/test_file_io.py
  function path (line 22) | def path(tmp_path: pathlib.Path) -> str:
  function wrapped (line 27) | def wrapped() -> mock.Mock:
  function async_file (line 32) | def async_file(wrapped: mock.Mock) -> AsyncIOWrapper[mock.Mock]:
  function test_wrap_invalid (line 36) | def test_wrap_invalid() -> None:
  function test_wrap_non_iobase (line 41) | def test_wrap_non_iobase() -> None:
  function test_wrapped_property (line 61) | def test_wrapped_property(
  function test_dir_matches_wrapped (line 68) | def test_dir_matches_wrapped(
  function test_unsupported_not_forwarded (line 82) | def test_unsupported_not_forwarded() -> None:
  function test_type_stubs_match_lists (line 96) | def test_type_stubs_match_lists() -> None:
  function test_sync_attrs_forwarded (line 136) | def test_sync_attrs_forwarded(
  function test_sync_attrs_match_wrapper (line 147) | def test_sync_attrs_match_wrapper(
  function test_async_methods_generated_once (line 162) | def test_async_methods_generated_once(async_file: AsyncIOWrapper[mock.Mo...
  function test_async_methods_signature (line 171) | def test_async_methods_signature(async_file: AsyncIOWrapper[mock.Mock]) ...
  function test_async_methods_wrap (line 180) | async def test_async_methods_wrap(
  function test_async_methods_match_wrapper (line 202) | def test_async_methods_match_wrapper(
  function test_open (line 217) | async def test_open(path: pathlib.Path) -> None:
  function test_open_context_manager (line 225) | async def test_open_context_manager(path: pathlib.Path) -> None:
  function test_async_iter (line 233) | async def test_async_iter() -> None:
  function test_aclose_cancelled (line 243) | async def test_aclose_cancelled(path: pathlib.Path) -> None:
  function test_detach_rewraps_asynciobase (line 257) | async def test_detach_rewraps_asynciobase(tmp_path: pathlib.Path) -> None:

FILE: src/trio/_tests/test_highlevel_generic.py
  class RecordSendStream (line 13) | class RecordSendStream(SendStream):
    method send_all (line 16) | async def send_all(self, data: object) -> None:
    method wait_send_all_might_not_block (line 19) | async def wait_send_all_might_not_block(self) -> None:
    method aclose (line 22) | async def aclose(self) -> None:
  class RecordReceiveStream (line 27) | class RecordReceiveStream(ReceiveStream):
    method receive_some (line 30) | async def receive_some(self, max_bytes: int | None = None) -> bytes:
    method aclose (line 34) | async def aclose(self) -> None:
  function test_StapledStream (line 38) | async def test_StapledStream() -> None:
  function test_StapledStream_with_erroring_close (line 78) | async def test_StapledStream_with_erroring_close() -> None:

FILE: src/trio/_tests/test_highlevel_open_tcp_listeners.py
  function test_open_tcp_listeners_basic (line 36) | async def test_open_tcp_listeners_basic() -> None:
  function test_open_tcp_listeners_specific_port_specific_host (line 64) | async def test_open_tcp_listeners_specific_port_specific_host() -> None:
  function test_open_tcp_listeners_ipv6_v6only (line 78) | async def test_open_tcp_listeners_ipv6_v6only() -> None:
  function test_open_tcp_listeners_rebind (line 93) | async def test_open_tcp_listeners_rebind() -> None:
  class FakeOSError (line 137) | class FakeOSError(OSError):
  class FakeSocket (line 142) | class FakeSocket(tsocket.SocketType):
    method type (line 152) | def type(self) -> SocketKind:
    method family (line 156) | def family(self) -> AddressFamily:
    method proto (line 160) | def proto(self) -> int:  # pragma: no cover
    method getsockopt (line 164) | def getsockopt(self, /, level: int, optname: int) -> int: ...
    method getsockopt (line 167) | def getsockopt(self, /, level: int, optname: int, buflen: int) -> byte...
    method getsockopt (line 169) | def getsockopt(
    method setsockopt (line 181) | def setsockopt(self, /, level: int, optname: int, value: int | Buffer)...
    method setsockopt (line 184) | def setsockopt(
    method setsockopt (line 193) | def setsockopt(
    method bind (line 203) | async def bind(self, address: AddressFormat) -> None:
    method listen (line 206) | def listen(self, /, backlog: int = min(stdlib_socket.SOMAXCONN, 128)) ...
    method close (line 213) | def close(self) -> None:
  class FakeSocketFactory (line 218) | class FakeSocketFactory(SocketFactory):
    method socket (line 223) | def socket(
  class FakeHostnameResolver (line 244) | class FakeHostnameResolver(HostnameResolver):
    method getaddrinfo (line 247) | async def getaddrinfo(
    method getnameinfo (line 270) | async def getnameinfo(
  function test_open_tcp_listeners_multiple_host_cleanup_on_error (line 278) | async def test_open_tcp_listeners_multiple_host_cleanup_on_error() -> None:
  function test_open_tcp_listeners_port_checking (line 302) | async def test_open_tcp_listeners_port_checking() -> None:
  function test_serve_tcp (line 312) | async def test_serve_tcp() -> None:
  function test_open_tcp_listeners_some_address_families_unavailable (line 335) | async def test_open_tcp_listeners_some_address_families_unavailable(
  function test_open_tcp_listeners_socket_fails_not_afnosupport (line 367) | async def test_open_tcp_listeners_socket_fails_not_afnosupport() -> None:
  function test_open_tcp_listeners_backlog (line 395) | async def test_open_tcp_listeners_backlog() -> None:
  function test_open_tcp_listeners_backlog_float_error (line 411) | async def test_open_tcp_listeners_backlog_float_error() -> None:

FILE: src/trio/_tests/test_highlevel_open_tcp_stream.py
  function test_close_all (line 29) | def test_close_all() -> None:
  function test_reorder_for_rfc_6555_section_5_4 (line 60) | def test_reorder_for_rfc_6555_section_5_4() -> None:
  function test_format_host_port (line 101) | def test_format_host_port() -> None:
  function test_open_tcp_stream_real_socket_smoketest (line 111) | async def test_open_tcp_stream_real_socket_smoketest() -> None:
  function test_open_tcp_stream_input_validation (line 126) | async def test_open_tcp_stream_input_validation() -> None:
  function can_bind_127_0_0_2 (line 133) | def can_bind_127_0_0_2() -> bool:
  function test_local_address_real (line 143) | async def test_local_address_real() -> None:
  class FakeSocket (line 197) | class FakeSocket(trio.socket.SocketType):
    method type (line 210) | def type(self) -> SocketKind:
    method family (line 214) | def family(self) -> AddressFamily:  # pragma: no cover
    method proto (line 218) | def proto(self) -> int:  # pragma: no cover
    method connect (line 221) | async def connect(self, sockaddr: tuple[str | int, str | int | None]) ...
    method close (line 235) | def close(self) -> None:
    method setsockopt (line 239) | def setsockopt(self, *args: object, **kwargs: object) -> None:
  class Scenario (line 246) | class Scenario(trio.abc.SocketFactory, trio.abc.HostnameResolver):
    method __init__ (line 247) | def __init__(
    method socket (line 270) | def socket(
    method _ip_to_gai_entry (line 284) | def _ip_to_gai_entry(self, ip: str) -> tuple[
    method getaddrinfo (line 300) | async def getaddrinfo(
    method getnameinfo (line 325) | async def getnameinfo(
    method check (line 332) | def check(self, succeeded: SocketType | None) -> None:
  function run_scenario (line 344) | async def run_scenario(
  function test_one_host_quick_success (line 391) | async def test_one_host_quick_success(autojump_clock: MockClock) -> None:
  function test_one_host_slow_success (line 398) | async def test_one_host_slow_success(autojump_clock: MockClock) -> None:
  function test_one_host_quick_fail (line 405) | async def test_one_host_quick_fail(autojump_clock: MockClock) -> None:
  function test_one_host_slow_fail (line 415) | async def test_one_host_slow_fail(autojump_clock: MockClock) -> None:
  function test_one_host_failed_after_connect (line 425) | async def test_one_host_failed_after_connect(autojump_clock: MockClock) ...
  function test_basic_fallthrough (line 435) | async def test_basic_fallthrough(autojump_clock: MockClock) -> None:
  function test_early_success (line 455) | async def test_early_success(autojump_clock: MockClock) -> None:
  function test_custom_delay (line 475) | async def test_custom_delay(autojump_clock: MockClock) -> None:
  function test_none_default (line 495) | async def test_none_default(autojump_clock: MockClock) -> None:
  function test_custom_errors_expedite (line 517) | async def test_custom_errors_expedite(autojump_clock: MockClock) -> None:
  function test_all_fail (line 539) | async def test_all_fail(autojump_clock: MockClock) -> None:
  function test_multi_success (line 567) | async def test_multi_success(autojump_clock: MockClock) -> None:
  function test_does_reorder (line 598) | async def test_does_reorder(autojump_clock: MockClock) -> None:
  function test_handles_no_ipv4 (line 619) | async def test_handles_no_ipv4(autojump_clock: MockClock) -> None:
  function test_handles_no_ipv6 (line 642) | async def test_handles_no_ipv6(autojump_clock: MockClock) -> None:
  function test_no_hosts (line 665) | async def test_no_hosts(autojump_clock: MockClock) -> None:
  function test_cancel (line 670) | async def test_cancel(autojump_clock: MockClock) -> None:

FILE: src/trio/_tests/test_highlevel_open_unix_stream.py
  function test_close_on_error (line 21) | def test_close_on_error() -> None:
  function test_open_with_bad_filename_type (line 40) | async def test_open_with_bad_filename_type(filename: float) -> None:
  function test_open_bad_socket (line 46) | async def test_open_bad_socket() -> None:
  function test_open_unix_socket (line 55) | async def test_open_unix_socket() -> None:
  function test_error_on_no_unix (line 81) | async def test_error_on_no_unix() -> None:

FILE: src/trio/_tests/test_highlevel_serve_listeners.py
  class MemoryListener (line 32) | class MemoryListener(trio.abc.Listener[StapledMemoryStream]):
    method connect (line 41) | async def connect(self) -> StapledMemoryStream:
    method accept (line 47) | async def accept(self) -> StapledMemoryStream:
    method aclose (line 56) | async def aclose(self) -> None:
  function test_serve_listeners_basic (line 61) | async def test_serve_listeners_basic() -> None:
  function test_serve_listeners_accept_unrecognized_error (line 112) | async def test_serve_listeners_accept_unrecognized_error() -> None:
  function test_serve_listeners_accept_capacity_error (line 128) | async def test_serve_listeners_accept_capacity_error(
  function test_serve_listeners_connection_nursery (line 152) | async def test_serve_listeners_connection_nursery(autojump_clock: MockCl...

FILE: src/trio/_tests/test_highlevel_socket.py
  function test_SocketStream_basics (line 23) | async def test_SocketStream_basics() -> None:
  function test_SocketStream_send_all (line 67) | async def test_SocketStream_send_all() -> None:
  function fill_stream (line 122) | async def fill_stream(s: SocketStream) -> None:
  function test_SocketStream_generic (line 136) | async def test_SocketStream_generic() -> None:
  function test_SocketListener (line 153) | async def test_SocketListener() -> None:
  function test_SocketListener_socket_closed_underfoot (line 212) | async def test_SocketListener_socket_closed_underfoot() -> None:
  function test_SocketListener_accept_errors (line 227) | async def test_SocketListener_accept_errors() -> None:
  function test_socket_stream_works_when_peer_has_already_closed (line 329) | async def test_socket_stream_works_when_peer_has_already_closed() -> None:

FILE: src/trio/_tests/test_highlevel_ssl_helpers.py
  function echo_handler (line 31) | async def echo_handler(stream: Stream) -> None:
  class FakeHostnameResolver (line 46) | class FakeHostnameResolver(trio.abc.HostnameResolver):
    method getaddrinfo (line 49) | async def getaddrinfo(
    method getnameinfo (line 68) | async def getnameinfo(
  function test_open_ssl_over_tcp_stream_and_everything_else (line 78) | async def test_open_ssl_over_tcp_stream_and_everything_else(
  function test_open_ssl_over_tcp_listeners (line 152) | async def test_open_ssl_over_tcp_listeners() -> None:

FILE: src/trio/_tests/test_path.py
  function path (line 17) | def path(tmp_path: pathlib.Path) -> trio.Path:
  function method_pair (line 21) | def method_pair(
  function test_instantiate_posix (line 31) | def test_instantiate_posix() -> None:
  function test_instantiate_windows (line 36) | def test_instantiate_windows() -> None:
  function test_open_is_async_context_manager (line 40) | async def test_open_is_async_context_manager(path: trio.Path) -> None:
  function test_magic (line 47) | def test_magic() -> None:
  function test_cmp_magic (line 64) | def test_cmp_magic(cls_a: EitherPathType, cls_b: EitherPathType) -> None:
  function test_div_magic (line 91) | def test_div_magic(cls_a: PathOrStrType, cls_b: PathOrStrType) -> None:
  function test_hash_magic (line 105) | def test_hash_magic(
  function test_forwarded_properties (line 114) | def test_forwarded_properties(path: trio.Path) -> None:
  function test_async_method_signature (line 121) | def test_async_method_signature(path: trio.Path) -> None:
  function test_compare_async_stat_methods (line 132) | async def test_compare_async_stat_methods(method_name: str) -> None:
  function test_invalid_name_not_wrapped (line 141) | def test_invalid_name_not_wrapped(path: trio.Path) -> None:
  function test_async_methods_rewrap (line 147) | async def test_async_methods_rewrap(method_name: str) -> None:
  function test_forward_methods_rewrap (line 157) | def test_forward_methods_rewrap(path: trio.Path, tmp_path: pathlib.Path)...
  function test_forward_properties_rewrap (line 167) | def test_forward_properties_rewrap(path: trio.Path) -> None:
  function test_forward_methods_without_rewrap (line 171) | def test_forward_methods_without_rewrap(path: trio.Path) -> None:
  function test_repr (line 175) | def test_repr() -> None:
  function test_path_wraps_path (line 182) | async def test_path_wraps_path(
  function test_path_nonpath (line 194) | def test_path_nonpath() -> None:
  function test_open_file_can_open_path (line 199) | async def test_open_file_can_open_path(path: trio.Path) -> None:
  function test_globmethods (line 204) | async def test_globmethods(path: trio.Path) -> None:
  function test_as_uri (line 233) | async def test_as_uri(path: trio.Path) -> None:
  function test_iterdir (line 239) | async def test_iterdir(path: trio.Path) -> None:
  function test_classmethods (line 253) | async def test_classmethods() -> None:
  function test_wrapping_without_docstrings (line 273) | def test_wrapping_without_docstrings(

FILE: src/trio/_tests/test_repl.py
  class RawInput (line 16) | class RawInput(Protocol):
    method __call__ (line 17) | def __call__(self, prompt: str = "") -> str: ...
  function build_raw_input (line 20) | def build_raw_input(cmds: list[str]) -> RawInput:
  function test_build_raw_input (line 39) | def test_build_raw_input() -> None:
  function test_basic_interaction (line 47) | async def test_basic_interaction(
  function test_system_exits_quit_interpreter (line 84) | async def test_system_exits_quit_interpreter(monkeypatch: pytest.MonkeyP...
  function test_KI_interrupts (line 96) | async def test_KI_interrupts(
  function test_system_exits_in_exc_group (line 124) | async def test_system_exits_in_exc_group(
  function test_system_exits_in_nested_exc_group (line 147) | async def test_system_exits_in_nested_exc_group(
  function test_base_exception_captured (line 171) | async def test_base_exception_captured(
  function test_exc_group_captured (line 191) | async def test_exc_group_captured(
  function test_base_exception_capture_from_coroutine (line 209) | async def test_base_exception_capture_from_coroutine(
  function test_main_entrypoint (line 233) | def test_main_entrypoint() -> None:
  function should_try_newline_injection (line 241) | def should_try_newline_injection() -> bool:
  function test_ki_newline_injection (line 257) | def test_ki_newline_injection() -> None:  # TODO: test this line
  function test_ki_in_repl (line 309) | async def test_ki_in_repl() -> None:

FILE: src/trio/_tests/test_scheduler_determinism.py
  function scheduler_trace (line 11) | async def scheduler_trace() -> tuple[tuple[str, int], ...]:
  function test_the_trio_scheduler_is_not_deterministic (line 27) | def test_the_trio_scheduler_is_not_deterministic() -> None:
  function test_the_trio_scheduler_is_deterministic_if_seeded (line 33) | def test_the_trio_scheduler_is_deterministic_if_seeded(

FILE: src/trio/_tests/test_signals.py
  function test_open_signal_receiver (line 17) | async def test_open_signal_receiver() -> None:
  function test_open_signal_receiver_restore_handler_after_one_bad_signal (line 41) | async def test_open_signal_receiver_restore_handler_after_one_bad_signal...
  function test_open_signal_receiver_empty_fail (line 53) | def test_open_signal_receiver_empty_fail() -> None:
  function test_open_signal_receiver_restore_handler_after_duplicate_signal (line 59) | async def test_open_signal_receiver_restore_handler_after_duplicate_sign...
  function test_catch_signals_wrong_thread (line 67) | async def test_catch_signals_wrong_thread() -> None:
  function test_open_signal_receiver_conflict (line 76) | async def test_open_signal_receiver_conflict() -> None:
  function wait_run_sync_soon_idempotent_queue_barrier (line 86) | async def wait_run_sync_soon_idempotent_queue_barrier() -> None:
  function test_open_signal_receiver_no_starvation (line 93) | async def test_open_signal_receiver_no_starvation() -> None:
  function test_catch_signals_race_condition_on_exit (line 124) | async def test_catch_signals_race_condition_on_exit() -> None:

FILE: src/trio/_tests/test_socket.py
  class MonkeypatchedGAI (line 52) | class MonkeypatchedGAI:
    method __init__ (line 55) | def __init__(
    method _frozenbind (line 70) | def _frozenbind(
    method set (line 86) | def set(
    method getaddrinfo (line 107) | def getaddrinfo(
  function monkeygai (line 127) | def monkeygai(monkeypatch: pytest.MonkeyPatch) -> MonkeypatchedGAI:
  function test__try_sync (line 133) | async def test__try_sync() -> None:
  function test_socket_has_some_reexports (line 163) | def test_socket_has_some_reexports() -> None:
  function test_getaddrinfo (line 175) | async def test_getaddrinfo(monkeygai: MonkeypatchedGAI) -> None:
  function test_getnameinfo (line 265) | async def test_getnameinfo() -> None:
  function test_from_stdlib_socket (line 300) | async def test_from_stdlib_socket() -> None:
  function test_from_fd (line 322) | async def test_from_fd() -> None:
  function test_socketpair_simple (line 331) | async def test_socketpair_simple() -> None:
  function test_fromshare (line 345) | async def test_fromshare() -> None:
  function test_socket (line 359) | async def test_socket() -> None:
  function test_socket_v6 (line 366) | async def test_socket_v6() -> None:
  function test_sniff_sockopts (line 373) | async def test_sniff_sockopts() -> None:
  function test_SocketType_basics (line 406) | async def test_SocketType_basics() -> None:
  function test_SocketType_setsockopt (line 457) | async def test_SocketType_setsockopt() -> None:
  function setsockopt_tests (line 463) | def setsockopt_tests(sock: SocketType | SocketStream) -> None:
  function test_SocketType_dup (line 498) | async def test_SocketType_dup() -> None:
  function test_SocketType_shutdown (line 510) | async def test_SocketType_shutdown() -> None:
  function test_SocketType_simple_server (line 544) | async def test_SocketType_simple_server(
  function test_SocketType_is_readable (line 564) | async def test_SocketType_is_readable() -> None:
  function gai_without_v4mapped_is_buggy (line 578) | def gai_without_v4mapped_is_buggy() -> bool:  # pragma: no cover
  class Addresses (line 588) | class Addresses:
  function test_SocketType_resolve (line 620) | async def test_SocketType_resolve(socket_type: AddressFamily, addrs: Add...
  function test_SocketType_unresolved_names (line 745) | async def test_SocketType_unresolved_names() -> None:
  function test_SocketType_non_blocking_paths (line 764) | async def test_SocketType_non_blocking_paths() -> None:
  function test_SocketType_connect_paths (line 840) | async def test_SocketType_connect_paths() -> None:
  function test_address_in_socket_error (line 914) | async def test_address_in_socket_error() -> None:
  function test_resolve_address_exception_in_connect_closes_socket (line 926) | async def test_resolve_address_exception_in_connect_closes_socket() -> N...
  function test_send_recv_variants (line 949) | async def test_send_recv_variants() -> None:
  function test_idna (line 1045) | async def test_idna(monkeygai: MonkeypatchedGAI) -> None:
  function test_getprotobyname (line 1063) | async def test_getprotobyname() -> None:
  function test_custom_hostname_resolver (line 1070) | async def test_custom_hostname_resolver(monkeygai: MonkeypatchedGAI) -> ...
  function test_custom_socket_factory (line 1131) | async def test_custom_socket_factory() -> None:
  function test_SocketType_is_abstract (line 1163) | def test_SocketType_is_abstract() -> None:
  function test_unix_domain_socket (line 1169) | async def test_unix_domain_socket() -> None:
  function test_interrupted_by_close (line 1201) | async def test_interrupted_by_close() -> None:
  function test_many_sockets (line 1231) | async def test_many_sockets() -> None:

FILE: src/trio/_tests/test_ssl.py
  function client_ctx (line 88) | def client_ctx(request: pytest.FixtureRequest) -> ssl.SSLContext:
  function ssl_echo_serve_sync (line 105) | def ssl_echo_serve_sync(
  function ssl_echo_server_raw (line 161) | async def ssl_echo_server_raw(expect_fail: bool = False) -> AsyncIterato...
  function ssl_echo_server (line 179) | async def ssl_echo_server(
  class PyOpenSSLEchoStream (line 192) | class PyOpenSSLEchoStream(Stream):
    method __init__ (line 193) | def __init__(
    method aclose (line 238) | async def aclose(self) -> None:
    method renegotiate_pending (line 241) | def renegotiate_pending(self) -> bool:
    method renegotiate (line 244) | def renegotiate(self) -> None:
    method wait_send_all_might_not_block (line 249) | async def wait_send_all_might_not_block(self) -> None:
    method send_all (line 255) | async def send_all(self, data: bytes) -> None:
    method receive_some (line 278) | async def receive_some(self, nbytes: int | None = None) -> bytes:
  function test_PyOpenSSLEchoStream_gives_resource_busy_errors (line 334) | async def test_PyOpenSSLEchoStream_gives_resource_busy_errors() -> None:
  function virtual_ssl_echo_server (line 367) | def virtual_ssl_echo_server(
  function ssl_wrap_pair (line 375) | def ssl_wrap_pair(  # type: ignore[explicit-any]
  function ssl_memory_stream_pair (line 405) | def ssl_memory_stream_pair(
  function ssl_lockstep_stream_pair (line 426) | def ssl_lockstep_stream_pair(
  function test_ssl_client_basics (line 447) | async def test_ssl_client_basics(client_ctx: SSLContext) -> None:
  function test_ssl_server_basics (line 473) | async def test_ssl_server_basics(client_ctx: SSLContext) -> None:
  function test_attributes (line 506) | async def test_attributes(client_ctx: SSLContext) -> None:
  function test_full_duplex_basics (line 575) | async def test_full_duplex_basics(client_ctx: SSLContext) -> None:
  function test_renegotiation_simple (line 612) | async def test_renegotiation_simple(client_ctx: SSLContext) -> None:
  function test_renegotiation_randomized (line 630) | async def test_renegotiation_randomized(
  function test_resource_busy_errors (line 752) | async def test_resource_busy_errors(client_ctx: SSLContext) -> None:
  function test_wait_writable_calls_underlying_wait_writable (line 787) | async def test_wait_writable_calls_underlying_wait_writable() -> None:
  function test_checkpoints (line 814) | async def test_checkpoints(client_ctx: SSLContext) -> None:
  function test_send_all_empty_string (line 843) | async def test_send_all_empty_string(client_ctx: SSLContext) -> None:
  function test_SSLStream_generic (line 860) | async def test_SSLStream_generic(
  function test_unwrap (line 893) | async def test_unwrap(client_ctx: SSLContext) -> None:
  function test_closing_nice_case (line 947) | async def test_closing_nice_case(client_ctx: SSLContext) -> None:
  function test_send_all_fails_in_the_middle (line 1009) | async def test_send_all_fails_in_the_middle(client_ctx: SSLContext) -> N...
  function test_ssl_over_ssl (line 1040) | async def test_ssl_over_ssl(client_ctx: SSLContext) -> None:
  function test_ssl_bad_shutdown (line 1070) | async def test_ssl_bad_shutdown(client_ctx: SSLContext) -> None:
  function test_ssl_bad_shutdown_but_its_ok (line 1087) | async def test_ssl_bad_shutdown_but_its_ok(client_ctx: SSLContext) -> None:
  function test_ssl_handshake_failure_during_aclose (line 1107) | async def test_ssl_handshake_failure_during_aclose() -> None:
  function test_ssl_only_closes_stream_once (line 1126) | async def test_ssl_only_closes_stream_once(client_ctx: SSLContext) -> None:
  function test_ssl_https_compatibility_disagreement (line 1152) | async def test_ssl_https_compatibility_disagreement(client_ctx: SSLConte...
  function test_https_mode_eof_before_handshake (line 1176) | async def test_https_mode_eof_before_handshake(client_ctx: SSLContext) -...
  function test_send_error_during_handshake (line 1191) | async def test_send_error_during_handshake(client_ctx: SSLContext) -> None:
  function test_receive_error_during_handshake (line 1208) | async def test_receive_error_during_handshake(client_ctx: SSLContext) ->...
  function test_selected_alpn_protocol_before_handshake (line 1231) | def test_selected_alpn_protocol_before_handshake(client_ctx: SSLContext)...
  function test_selected_alpn_protocol_when_not_set (line 1241) | async def test_selected_alpn_protocol_when_not_set(client_ctx: SSLContex...
  function test_selected_npn_protocol_before_handshake (line 1256) | def test_selected_npn_protocol_before_handshake(client_ctx: SSLContext) ...
  function test_selected_npn_protocol_when_not_set (line 1270) | async def test_selected_npn_protocol_when_not_set(client_ctx: SSLContext...
  function test_get_channel_binding_before_handshake (line 1285) | def test_get_channel_binding_before_handshake(client_ctx: SSLContext) ->...
  function test_get_channel_binding_after_handshake (line 1295) | async def test_get_channel_binding_after_handshake(client_ctx: SSLContex...
  function test_getpeercert (line 1308) | async def test_getpeercert(client_ctx: SSLContext) -> None:
  function test_SSLListener (line 1321) | async def test_SSLListener(client_ctx: SSLContext) -> None:

FILE: src/trio/_tests/test_subprocess.py
  function python (line 64) | def python(code: str) -> list[str]:
  function SLEEP (line 74) | def SLEEP(seconds: int) -> list[str]:
  function SLEEP (line 79) | def SLEEP(seconds: int) -> list[str]:
  function open_process_then_kill (line 84) | async def open_process_then_kill(  # type: ignore[misc, explicit-any]
  function run_process_in_nursery (line 97) | async def run_process_in_nursery(  # type: ignore[misc, explicit-any]
  function test_basic (line 123) | async def test_basic(background_process: BackgroundProcessType) -> None:
  function test_basic_no_pidfd (line 141) | async def test_basic_no_pidfd(background_process: BackgroundProcessType)...
  function test_auto_update_returncode (line 161) | async def test_auto_update_returncode(
  function test_multi_wait (line 176) | async def test_multi_wait(background_process: BackgroundProcessType) -> ...
  function test_multi_wait_no_pidfd (line 196) | async def test_multi_wait_no_pidfd(background_process: BackgroundProcess...
  function test_pipes (line 224) | async def test_pipes(background_process: BackgroundProcessType) -> None:
  function test_interactive (line 259) | async def test_interactive(background_process: BackgroundProcessType) ->...
  function test_run (line 335) | async def test_run() -> None:
  function test_run_check (line 392) | async def test_run_check() -> None:
  function test_run_with_broken_pipe (line 414) | async def test_run_with_broken_pipe() -> None:
  function test_stderr_stdout (line 424) | async def test_stderr_stdout(background_process: BackgroundProcessType) ...
  function test_errors (line 493) | async def test_errors() -> None:
  function test_signals (line 508) | async def test_signals(background_process: BackgroundProcessType) -> None:
  function test_wait_reapable_fails (line 539) | async def test_wait_reapable_fails(background_process: BackgroundProcess...
  function test_wait_reapable_fails_no_pidfd (line 561) | async def test_wait_reapable_fails_no_pidfd(
  function test_waitid_eintr (line 585) | def test_waitid_eintr() -> None:
  function test_custom_deliver_cancel (line 625) | async def test_custom_deliver_cancel() -> None:
  function test_bad_deliver_cancel (line 649) | def test_bad_deliver_cancel() -> None:
  function test_warn_on_failed_cancel_terminate (line 669) | async def test_warn_on_failed_cancel_terminate(monkeypatch: pytest.Monke...
  function test_warn_on_cancel_SIGKILL_escalation (line 686) | async def test_warn_on_cancel_SIGKILL_escalation(
  function test_run_process_background_fail (line 701) | async def test_run_process_background_fail() -> None:
  function test_for_leaking_fds (line 714) | async def test_for_leaking_fds() -> None:
  function test_run_process_internal_error (line 730) | async def test_run_process_internal_error(monkeypatch: pytest.MonkeyPatc...
  function test_subprocess_pidfd_unnotified (line 742) | async def test_subprocess_pidfd_unnotified() -> None:

FILE: src/trio/_tests/test_sync.py
  function test_Event (line 17) | async def test_Event() -> None:
  function test_CapacityLimiter (line 53) | async def test_CapacityLimiter() -> None:
  function test_CapacityLimiter_inf (line 123) | async def test_CapacityLimiter_inf() -> None:
  function test_CapacityLimiter_change_total_tokens (line 139) | async def test_CapacityLimiter_change_total_tokens() -> None:
  function test_CapacityLimiter_memleak_548 (line 176) | async def test_CapacityLimiter_memleak_548() -> None:
  function test_CapacityLimiter_zero_limit_tokens (line 190) | async def test_CapacityLimiter_zero_limit_tokens() -> None:
  function test_Semaphore (line 267) | async def test_Semaphore() -> None:
  function test_Semaphore_bounded (line 315) | def test_Semaphore_bounded() -> None:
  function test_Lock_and_StrictFIFOLock (line 333) | async def test_Lock_and_StrictFIFOLock(
  function test_Condition (line 410) | async def test_Condition() -> None:
  class ChannelLock1 (line 501) | class ChannelLock1(AsyncContextManagerMixin):
    method __init__ (line 502) | def __init__(self, capacity: int) -> None:
    method acquire_nowait (line 507) | def acquire_nowait(self) -> None:
    method acquire (line 510) | async def acquire(self) -> None:
    method release (line 513) | def release(self) -> None:
  class ChannelLock2 (line 517) | class ChannelLock2(AsyncContextManagerMixin):
    method __init__ (line 518) | def __init__(self) -> None:
    method acquire_nowait (line 522) | def acquire_nowait(self) -> None:
    method acquire (line 525) | async def acquire(self) -> None:
    method release (line 528) | def release(self) -> None:
  class ChannelLock3 (line 532) | class ChannelLock3(AsyncContextManagerMixin):
    method __init__ (line 533) | def __init__(self) -> None:
    method acquire_nowait (line 540) | def acquire_nowait(self) -> None:
    method acquire (line 544) | async def acquire(self) -> None:
    method release (line 551) | def release(self) -> None:
  function test_generic_lock_exclusion (line 601) | async def test_generic_lock_exclusion(lock_factory: LockFactory) -> None:
  function test_generic_lock_fifo_fairness (line 630) | async def test_generic_lock_fifo_fairness(lock_factory: LockFactory) -> ...
  function test_generic_lock_acquire_nowait_blocks_acquire (line 654) | async def test_generic_lock_acquire_nowait_blocks_acquire(
  function test_lock_acquire_unowned_lock (line 675) | async def test_lock_acquire_unowned_lock() -> None:
  function test_lock_multiple_acquire (line 692) | async def test_lock_multiple_acquire() -> None:
  function test_lock_handover (line 709) | async def test_lock_handover() -> None:

FILE: src/trio/_tests/test_testing.py
  function test_wait_all_tasks_blocked (line 22) | async def test_wait_all_tasks_blocked() -> None:
  function test_wait_all_tasks_blocked_with_timeouts (line 54) | async def test_wait_all_tasks_blocked_with_timeouts(mock_clock: MockCloc...
  function test_wait_all_tasks_blocked_with_cushion (line 71) | async def test_wait_all_tasks_blocked_with_cushion() -> None:
  function test_assert_checkpoints (line 113) | async def test_assert_checkpoints(recwarn: pytest.WarningsRecorder) -> N...
  function test_assert_no_checkpoints (line 139) | async def test_assert_no_checkpoints(recwarn: pytest.WarningsRecorder) -...
  function test_Sequencer (line 169) | async def test_Sequencer() -> None:
  function test_Sequencer_cancel (line 207) | async def test_Sequencer_cancel() -> None:
  function test__assert_raises (line 237) | def test__assert_raises() -> None:
  function test__UnboundeByteQueue (line 252) | async def test__UnboundeByteQueue() -> None:
  function test_MemorySendStream (line 324) | async def test_MemorySendStream() -> None:
  function test_MemoryReceiveStream (line 416) | async def test_MemoryReceiveStream() -> None:
  function test_MemoryRecvStream_closing (line 477) | async def test_MemoryRecvStream_closing() -> None:
  function test_memory_stream_pump (line 497) | async def test_memory_stream_pump() -> None:
  function test_memory_stream_one_way_pair (line 521) | async def test_memory_stream_one_way_pair() -> None:
  function test_memory_stream_pair (line 577) | async def test_memory_stream_pair() -> None:
  function test_memory_streams_with_generic_tests (line 599) | async def test_memory_streams_with_generic_tests() -> None:
  function test_lockstep_streams_with_generic_tests (line 614) | async def test_lockstep_streams_with_generic_tests() -> None:
  function test_open_stream_to_socket_listener (line 629) | async def test_open_stream_to_socket_listener() -> None:
  function test_trio_test (line 671) | def test_trio_test() -> None:

FILE: src/trio/_tests/test_testing_raisesgroup.py
  function wrap_escape (line 17) | def wrap_escape(s: str) -> str:
  function fails_raises_group (line 21) | def fails_raises_group(
  function test_raises_group (line 31) | def test_raises_group() -> None:
  function test_incorrect_number_exceptions (line 75) | def test_incorrect_number_exceptions() -> None:
  function test_flatten_subgroups (line 137) | def test_flatten_subgroups() -> None:
  function test_catch_unwrapped_exceptions (line 260) | def test_catch_unwrapped_exceptions() -> None:
  function test_match (line 340) | def test_match() -> None:
  function test_check (line 383) | def test_check() -> None:
  function test_unwrapped_match_check (line 400) | def test_unwrapped_match_check() -> None:
  function test_RaisesGroup_matches (line 431) | def test_RaisesGroup_matches() -> None:
  function test_message (line 438) | def test_message() -> None:
  function test_assert_message (line 497) | def test_assert_message() -> None:
  function test_message_indent (line 615) | def test_message_indent() -> None:
  function test_suggestion_on_nested_and_brief_error (line 683) | def test_suggestion_on_nested_and_brief_error() -> None:
  function test_assert_message_nested (line 748) | def test_assert_message_nested() -> None:
  function test_check_no_patched_repr (line 835) | def test_check_no_patched_repr() -> None:
  function test_misordering_example (line 862) | def test_misordering_example() -> None:
  function test_brief_error_on_one_fail (line 895) | def test_brief_error_on_one_fail() -> None:
  function test_identity_oopsies (line 940) | def test_identity_oopsies() -> None:
  function test_matcher (line 983) | def test_matcher() -> None:
  function test_matcher_match (line 1006) | def test_matcher_match() -> None:
  function test_Matcher_check (line 1040) | def test_Matcher_check() -> None:
  function test_matcher_tostring (line 1074) | def test_matcher_tostring() -> None:
  function test_raisesgroup_tostring (line 1087) | def test_raisesgroup_tostring() -> None:
  function test__ExceptionInfo (line 1104) | def test__ExceptionInfo(monkeypatch: pytest.MonkeyPatch) -> None:
  function test_raisesgroup_matcher_deprecation (line 1117) | def test_raisesgroup_matcher_deprecation() -> None:

FILE: src/trio/_tests/test_threads.py
  function test_do_in_trio_thread (line 54) | async def test_do_in_trio_thread() -> None:
  function test_do_in_trio_thread_from_trio_thread (line 114) | async def test_do_in_trio_thread_from_trio_thread() -> None:
  function test_run_in_trio_thread_ki (line 125) | def test_run_in_trio_thread_ki() -> None:
  function test_await_in_trio_thread_while_main_exits (line 173) | def test_await_in_trio_thread_while_main_exits() -> None:
  function test_named_thread (line 201) | async def test_named_thread() -> None:
  function _get_thread_name (line 230) | def _get_thread_name(ident: int | None = None) -> str | None:
  function test_named_thread_os (line 276) | async def test_named_thread_os() -> None:
  function test_has_pthread_setname_np (line 311) | def test_has_pthread_setname_np() -> None:
  function test_run_in_worker_thread (line 320) | async def test_run_in_worker_thread() -> None:
  function test_run_in_worker_thread_cancellation (line 342) | async def test_run_in_worker_thread_cancellation() -> None:
  function test_run_in_worker_thread_abandoned (line 402) | def test_run_in_worker_thread_abandoned(
  function test_run_in_worker_thread_limiter (line 443) | async def test_run_in_worker_thread_limiter(
  function test_run_in_worker_thread_custom_limiter (line 559) | async def test_run_in_worker_thread_custom_limiter() -> None:
  function test_run_in_worker_thread_limiter_error (line 579) | async def test_run_in_worker_thread_limiter_error() -> None:
  function test_run_in_worker_thread_fail_to_spawn (line 607) | async def test_run_in_worker_thread_fail_to_spawn(
  function test_trio_to_thread_run_sync_token (line 627) | async def test_trio_to_thread_run_sync_token() -> None:
  function test_trio_to_thread_run_sync_expected_error (line 639) | async def test_trio_to_thread_run_sync_expected_error() -> None:
  function test_trio_to_thread_run_sync_contextvars (line 653) | async def test_trio_to_thread_run_sync_contextvars() -> None:
  function test_trio_from_thread_run_sync (line 690) | async def test_trio_from_thread_run_sync() -> None:
  function test_trio_from_thread_run (line 711) | async def test_trio_from_thread_run() -> None:
  function test_trio_from_thread_token (line 735) | async def test_trio_from_thread_token() -> None:
  function test_trio_from_thread_token_kwarg (line 747) | async def test_trio_from_thread_token_kwarg() -> None:
  function test_from_thread_no_token (line 759) | async def test_from_thread_no_token() -> None:
  function test_trio_from_thread_run_sync_contextvars (line 767) | async def test_trio_from_thread_run_sync_contextvars() -> None:
  function test_trio_from_thread_run_contextvars (line 810) | async def test_trio_from_thread_run_contextvars() -> None:
  function test_run_fn_as_system_task_caught_badly_typed_token (line 853) | def test_run_fn_as_system_task_caught_badly_typed_token() -> None:
  function test_from_thread_inside_trio_thread (line 861) | async def test_from_thread_inside_trio_thread() -> None:
  function test_from_thread_run_during_shutdown (line 870) | def test_from_thread_run_during_shutdown() -> None:
  function test_trio_token_weak_referenceable (line 897) | async def test_trio_token_weak_referenceable() -> None:
  function test_unsafe_abandon_on_cancel_kwarg (line 904) | async def test_unsafe_abandon_on_cancel_kwarg() -> None:
  function test_from_thread_reuses_task (line 915) | async def test_from_thread_reuses_task() -> None:
  function test_recursive_to_thread (line 925) | async def test_recursive_to_thread() -> None:
  function test_from_thread_host_cancelled (line 936) | async def test_from_thread_host_cancelled() -> None:
  function child (line 995) | async def child(
  function test_from_thread_check_cancelled_no_abandon (line 1013) | async def test_from_thread_check_cancelled_no_abandon(cancel_the_scope: ...
  function test_from_thread_check_cancelled_abandon_on_cancel (line 1056) | async def test_from_thread_check_cancelled_abandon_on_cancel() -> None:
  function test_from_thread_check_cancelled_raises_in_foreign_threads (line 1104) | def test_from_thread_check_cancelled_raises_in_foreign_threads() -> None:
  function test_reentry_doesnt_deadlock (line 1114) | async def test_reentry_doesnt_deadlock() -> None:
  function test_wait_all_threads_completed (line 1129) | async def test_wait_all_threads_completed() -> None:
  function test_wait_all_threads_completed_no_threads (line 1171) | async def test_wait_all_threads_completed_no_threads() -> None:

FILE: src/trio/_tests/test_timeouts.py
  function check_takes_about (line 31) | async def check_takes_about(f: Callable[[], Awaitable[T]], expected_dur:...
  function test_sleep (line 66) | async def test_sleep() -> None:
  function test_move_on_after (line 86) | async def test_move_on_after() -> None:
  function test_cannot_wake_sleep_forever (line 94) | async def test_cannot_wake_sleep_forever() -> None:
  class TimeoutScope (line 108) | class TimeoutScope(Protocol):
    method __call__ (line 109) | def __call__(self, seconds: float, *, shield: bool) -> trio.CancelScop...
  function test_context_shields_from_outer (line 113) | async def test_context_shields_from_outer(scope: TimeoutScope) -> None:
  function test_move_on_after_moves_on_even_if_shielded (line 126) | async def test_move_on_after_moves_on_even_if_shielded() -> None:
  function test_fail_after_fails_even_if_shielded (line 138) | async def test_fail_after_fails_even_if_shielded() -> None:
  function test_fail (line 157) | async def test_fail() -> None:
  function test_timeouts_raise_value_error (line 179) | async def test_timeouts_raise_value_error() -> None:
  function test_timeout_deadline_on_entry (line 212) | async def test_timeout_deadline_on_entry(mock_clock: _core.MockClock) ->...
  function test_invalid_access_unentered (line 246) | async def test_invalid_access_unentered(mock_clock: _core.MockClock) -> ...
  function test_fail_access_before_entering (line 277) | async def test_fail_access_before_entering() -> None:  # pragma: no cover

FILE: src/trio/_tests/test_tracing.py
  function coro1 (line 11) | async def coro1(event: trio.Event) -> None:
  function coro2 (line 16) | async def coro2(event: trio.Event) -> None:
  function coro3 (line 20) | async def coro3(event: trio.Event) -> None:
  function coro2_async_gen (line 24) | async def coro2_async_gen(event: trio.Event) -> AsyncGenerator[None, None]:
  function coro3_async_gen (line 35) | async def coro3_async_gen(event: trio.Event) -> None:
  function test_task_iter_await_frames (line 40) | async def test_task_iter_await_frames() -> None:
  function test_task_iter_await_frames_async_gen (line 57) | async def test_task_iter_await_frames_async_gen() -> None:
  function test_closed_task_iter_await_frames (line 74) | async def test_closed_task_iter_await_frames() -> None:

FILE: src/trio/_tests/test_trio.py
  function test_trio_import (line 1) | def test_trio_import() -> None:

FILE: src/trio/_tests/test_unix_pipes.py
  function make_pipe (line 27) | async def make_pipe() -> tuple[FdStream, FdStream]:
  function make_clogged_pipe (line 33) | async def make_clogged_pipe() -> tuple[FdStream, FdStream]:
  function test_send_pipe (line 59) | async def test_send_pipe() -> None:
  function test_receive_pipe (line 69) | async def test_receive_pipe() -> None:
  function test_pipes_combined (line 79) | async def test_pipes_combined() -> None:
  function test_pipe_errors (line 103) | async def test_pipe_errors() -> None:
  function test_del (line 114) | async def test_del() -> None:
  function test_async_with (line 129) | async def test_async_with() -> None:
  function test_misdirected_aclose_regression (line 146) | async def test_misdirected_aclose_regression() -> None:
  function test_close_at_bad_time_for_receive_some (line 184) | async def test_close_at_bad_time_for_receive_some(
  function test_close_at_bad_time_for_send_all (line 217) | async def test_close_at_bad_time_for_send_all(monkeypatch: pytest.Monkey...
  function test_bizarro_OSError_from_receive (line 267) | async def test_bizarro_OSError_from_receive() -> None:
  function test_pipe_fully (line 287) | async def test_pipe_fully() -> None:

FILE: src/trio/_tests/test_util.py
  function test_ConflictDetector (line 40) | async def test_ConflictDetector() -> None:
  function test_module_metadata_is_fixed_up (line 63) | def test_module_metadata_is_fixed_up() -> None:
  function test_is_main_thread (line 87) | async def test_is_main_thread() -> None:
  function test_coroutine_or_error (line 98) | def test_coroutine_or_error() -> None:
  function test_final_decorator (line 161) | def test_final_decorator() -> None:
  function test_no_public_constructor_metaclass (line 178) | def test_no_public_constructor_metaclass() -> None:
  function test_fixup_module_metadata (line 194) | def test_fixup_module_metadata() -> None:
  function test_raise_single_exception_from_group (line 262) | async def test_raise_single_exception_from_group() -> None:

FILE: src/trio/_tests/test_wait_for_object.py
  function test_WaitForMultipleObjects_sync (line 19) | def test_WaitForMultipleObjects_sync() -> None:
  function test_WaitForMultipleObjects_sync_slow (line 73) | async def test_WaitForMultipleObjects_sync_slow() -> None:
  function test_WaitForSingleObject (line 136) | async def test_WaitForSingleObject() -> None:
  function test_WaitForSingleObject_slow (line 171) | async def test_WaitForSingleObject_slow() -> None:

FILE: src/trio/_tests/test_windows_pipes.py
  function make_pipe (line 25) | async def make_pipe() -> tuple[PipeSendStream, PipeReceiveStream]:
  function test_pipe_typecheck (line 31) | def test_pipe_typecheck() -> None:
  function test_pipe_error_on_close (line 38) | async def test_pipe_error_on_close() -> None:
  function test_pipes_combined (line 54) | async def test_pipes_combined() -> None:
  function test_async_with (line 83) | async def test_async_with() -> None:
  function test_close_during_write (line 94) | async def test_close_during_write() -> None:
  function test_pipe_fully (line 109) | async def test_pipe_fully() -> None:

FILE: src/trio/_tests/tools/test_gen_exports.py
  function test_get_public_methods (line 65) | def test_get_public_methods() -> None:
  function test_create_pass_through_args (line 70) | def test_create_pass_through_args() -> None:
  function test_process (line 97) | def test_process(
  function test_run_ruff (line 139) | def test_run_ruff(tmp_path: Path) -> None:
  function test_lint_failure (line 165) | def test_lint_failure(tmp_path: Path) -> None:

FILE: src/trio/_tests/tools/test_mypy_annotate.py
  function test_processing (line 56) | def test_processing(src: str, expected: Result | None) -> None:
  function test_export (line 61) | def test_export(capsys: pytest.CaptureFixture[str]) -> None:
  function test_endtoend (line 103) | def test_endtoend(

FILE: src/trio/_tests/tools/test_sync_requirements.py
  function test_yield_pre_commit_version_data (line 23) | def test_yield_pre_commit_version_data() -> None:
  function test_update_requirements (line 39) | def test_update_requirements(
  function test_update_requirements_no_changes (line 64) | def test_update_requirements_no_changes(

FILE: src/trio/_tests/type_tests/check_wraps.py
  function fn (line 7) | async def fn(s: trio.SocketStream) -> None:

FILE: src/trio/_tests/type_tests/path.py
  function operator_checks (line 14) | def operator_checks(text: str, tpath: trio.Path, ppath: pathlib.Path) ->...
  function sync_attrs (line 37) | def sync_attrs(path: trio.Path) -> None:
  function async_attrs (line 63) | async def async_attrs(path: trio.Path) -> None:
  function open_results (line 117) | async def open_results(path: trio.Path, some_int: int, some_str: str) ->...

FILE: src/trio/_tests/type_tests/subprocesses.py
  function test (line 6) | async def test() -> None:

FILE: src/trio/_tests/type_tests/task_status.py
  function check_status (line 7) | def check_status(

FILE: src/trio/_threads.py
  class _ParentTaskData (line 41) | class _ParentTaskData(threading.local):
  class _ActiveThreadCount (line 61) | class _ActiveThreadCount:
  function _track_active_thread (line 70) | def _track_active_thread() -> Generator[None, None, None]:
  function wait_all_threads_completed (line 87) | async def wait_all_threads_completed() -> None:
  function active_thread_count (line 115) | def active_thread_count() -> int:
  function current_default_thread_limiter (line 126) | def current_default_thread_limiter() -> CapacityLimiter:
  class ThreadPlaceholder (line 147) | class ThreadPlaceholder:
  class Run (line 153) | class Run(Generic[RetT]):  # type: ignore[explicit-any]
    method unprotected_afn (line 166) | async def unprotected_afn(self) -> RetT:
    method run (line 170) | async def run(self) -> None:
    method run_system (line 181) | async def run_system(self) -> None:
    method run_in_host_task (line 185) | def run_in_host_task(self, token: TrioToken) -> None:
    method run_in_system_nursery (line 195) | def run_in_system_nursery(self, token: TrioToken) -> None:
  class RunSync (line 212) | class RunSync(Generic[RetT]):  # type: ignore[explicit-any]
    method unprotected_fn (line 225) | def unprotected_fn(self) -> RetT:
    method run_sync (line 238) | def run_sync(self) -> None:
    method run_in_host_task (line 242) | def run_in_host_task(self, token: TrioToken) -> None:
    method run_in_system_nursery (line 252) | def run_in_system_nursery(self, token: TrioToken) -> None:
  function to_thread_run_sync (line 257) | async def to_thread_run_sync(
  function from_thread_check_cancelled (line 461) | def from_thread_check_cancelled() -> None:
  function _send_message_to_trio (line 498) | def _send_message_to_trio(
  function from_thread_run (line 531) | def from_thread_run(
  function from_thread_run_sync (line 575) | def from_thread_run_sync(

FILE: src/trio/_timeouts.py
  function move_on_at (line 14) | def move_on_at(deadline: float, *, shield: bool = False) -> trio.CancelS...
  function move_on_after (line 31) | def move_on_after(
  function sleep_forever (line 61) | async def sleep_forever() -> NoReturn:
  function sleep_until (line 75) | async def sleep_until(deadline: float) -> None:
  function sleep (line 95) | async def sleep(seconds: float) -> None:
  class TooSlowError (line 114) | class TooSlowError(Exception):
  function fail_at (line 122) | def fail_at(
  function fail_after (line 156) | def fail_after(

FILE: src/trio/_tools/gen_exports.py
  class File (line 48) | class File:
  function is_function (line 55) | def is_function(node: ast.AST) -> TypeGuard[ast.FunctionDef | ast.AsyncF...
  function is_public (line 62) | def is_public(node: ast.AST) -> TypeGuard[ast.FunctionDef | ast.AsyncFun...
  function get_public_methods (line 71) | def get_public_methods(
  function create_passthrough_args (line 84) | def create_passthrough_args(funcdef: ast.FunctionDef | ast.AsyncFunction...
  function run_black (line 102) | def run_black(file: File, source: str) -> tuple[bool, str]:
  function run_ruff (line 133) | def run_ruff(file: File, source: str) -> tuple[bool, str]:
  function run_linters (line 171) | def run_linters(file: File, source: str) -> str:
  function gen_public_wrappers_source (line 191) | def gen_public_wrappers_source(file: File) -> str:
  function matches_disk_files (line 264) | def matches_disk_files(new_files: dict[str, str]) -> bool:
  function process (line 274) | def process(files: Iterable[File], *, do_test: bool) -> None:
  function main (line 301) | def main() -> None:  # pragma: no cover

FILE: src/trio/_tools/mypy_annotate.py
  class Result (line 41) | class Result:
  function process_line (line 53) | def process_line(line: str) -> Result | None:
  function export (line 69) | def export(results: dict[Result, list[str]]) -> None:
  function main (line 85) | def main(argv: list[str]) -> None:

FILE: src/trio/_tools/sync_requirements.py
  function yield_pre_commit_version_data (line 27) | def yield_pre_commit_version_data(
  function update_requirements (line 41) | def update_requirements(

FILE: src/trio/_unix_pipes.py
  class _FdHolder (line 20) | class _FdHolder:
    method __init__ (line 40) | def __init__(self, fd: int) -> None:
    method closed (line 52) | def closed(self) -> bool:
    method _raw_close (line 55) | def _raw_close(self) -> None:
    method __del__ (line 70) | def __del__(self) -> None:
    method close (line 73) | def close(self) -> None:
  class FdStream (line 80) | class FdStream(Stream):
    method __init__ (line 121) | def __init__(self, fd: int) -> None:
    method send_all (line 130) | async def send_all(self, data: bytes) -> None:
    method wait_send_all_might_not_block (line 155) | async def wait_send_all_might_not_block(self) -> None:
    method receive_some (line 161) | async def receive_some(self, max_bytes: int | None = None) -> bytes:
    method close (line 189) | def close(self) -> None:
    method aclose (line 192) | async def aclose(self) -> None:
    method fileno (line 196) | def fileno(self) -> int:

FILE: src/trio/_util.py
  function is_main_thread (line 46) | def is_main_thread() -> bool:
  function coroutine_or_error (line 59) | def coroutine_or_error(
  class ConflictDetector (line 148) | class ConflictDetector:
    method __init__ (line 162) | def __init__(self, msg: str) -> None:
    method __enter__ (line 166) | def __enter__(self) -> None:
    method __exit__ (line 172) | def __exit__(
  function async_wraps (line 181) | def async_wraps(  # type: ignore[explicit-any]
  function fixup_module_metadata (line 199) | def fixup_module_metadata(
  function _init_final_cls (line 231) | def _init_final_cls(cls: type[object]) -> NoReturn:
  function _final_impl (line 236) | def _final_impl(decorated: type[T]) -> type[T]:
  class NoPublicConstructor (line 265) | class NoPublicConstructor(ABCMeta):
    method __call__ (line 285) | def __call__(cls, *args: object, **kwargs: object) -> None:
    method _create (line 290) | def _create(cls: type[T], *args: object, **kwargs: object) -> T:
  function name_asyncgen (line 294) | def name_asyncgen(agen: AsyncGeneratorType[object, NoReturn]) -> str:
  function wraps (line 315) | def wraps(  # type: ignore[explicit-any]
  function raise_saving_context (line 325) | def raise_saving_context(exc: BaseException) -> NoReturn:
  class MultipleExceptionError (line 338) | class MultipleExceptionError(Exception):
  function raise_single_exception_from_group (line 343) | def raise_single_exception_from_group(

FILE: src/trio/_wait_for_object.py
  function WaitForSingleObject (line 18) | async def WaitForSingleObject(obj: int | CData) -> None:
  function WaitForMultipleObjects_sync (line 58) | def WaitForMultipleObjects_sync(*handles: int | CData) -> None:

FILE: src/trio/_windows_pipes.py
  class _HandleHolder (line 19) | class _HandleHolder:
    method __init__ (line 20) | def __init__(self, handle: int) -> None:
    method closed (line 28) | def closed(self) -> bool:
    method close (line 31) | def close(self) -> None:
    method __del__ (line 39) | def __del__(self) -> None:
  class PipeSendStream (line 44) | class PipeSendStream(SendStream):
    method __init__ (line 49) | def __init__(self, handle: int) -> None:
    method send_all (line 55) | async def send_all(self, data: bytes) -> None:
    method wait_send_all_might_not_block (line 73) | async def wait_send_all_might_not_block(self) -> None:
    method close (line 81) | def close(self) -> None:
    method aclose (line 84) | async def aclose(self) -> None:
  class PipeReceiveStream (line 90) | class PipeReceiveStream(ReceiveStream):
    method __init__ (line 93) | def __init__(self, handle: int) -> None:
    method receive_some (line 99) | async def receive_some(self, max_bytes: int | None = None) -> bytes:
    method close (line 139) | def close(self) -> None:
    method aclose (line 142) | async def aclose(self) -> None:

FILE: src/trio/testing/_check_streams.py
  class _ForceCloseBoth (line 35) | class _ForceCloseBoth(Generic[Res1, Res2]):
    method __init__ (line 36) | def __init__(self, both: tuple[Res1, Res2]) -> None:
    method __aenter__ (line 39) | async def __aenter__(self) -> tuple[Res1, Res2]:
    method __aexit__ (line 42) | async def __aexit__(
  function _assert_raises (line 57) | def _assert_raises(
  function check_one_way_stream (line 75) | async def check_one_way_stream(
  function check_two_way_stream (line 425) | async def check_two_way_stream(
  function check_half_closeable_stream (line 505) | async def check_half_closeable_stream(

FILE: src/trio/testing/_checkpoints.py
  function _assert_yields_or_not (line 13) | def _assert_yields_or_not(expected: bool) -> Generator[None, None, None]:
  function assert_checkpoints (line 32) | def assert_checkpoints() -> AbstractContextManager[None]:
  function assert_no_checkpoints (line 52) | def assert_no_checkpoints() -> AbstractContextManager[None]:

FILE: src/trio/testing/_fake_net.py
  function _family_for (line 37) | def _family_for(ip: IPAddress) -> int:
  function _wildcard_ip_for (line 45) | def _wildcard_ip_for(family: int) -> IPAddress:
  function _localhost_ip_for (line 54) | def _localhost_ip_for(family: int) -> IPAddress:  # pragma: no cover
  function _fake_err (line 62) | def _fake_err(code: int) -> NoReturn:
  function _scatter (line 66) | def _scatter(data: bytes, buffers: Iterable[Buffer]) -> int:
  class UDPEndpoint (line 79) | class UDPEndpoint:
    method as_python_sockaddr (line 83) | def as_python_sockaddr(self) -> tuple[str, int] | tuple[str, int, int,...
    method from_python_sockaddr (line 93) | def from_python_sockaddr(
  class UDPBinding (line 102) | class UDPBinding:
  class UDPPacket (line 108) | class UDPPacket:
    method reply (line 114) | def reply(self, payload: bytes) -> UDPPacket:  # pragma: no cover
  class FakeSocketFactory (line 123) | class FakeSocketFactory(trio.abc.SocketFactory):
    method socket (line 126) | def socket(self, family: int, type_: int, proto: int) -> FakeSocket:  ...
  class FakeHostnameResolver (line 131) | class FakeHostnameResolver(trio.abc.HostnameResolver):
    method getaddrinfo (line 134) | async def getaddrinfo(
    method getnameinfo (line 153) | async def getnameinfo(
  class FakeNet (line 162) | class FakeNet:
    method __init__ (line 163) | def __init__(self) -> None:
    method _bind (line 173) | def _bind(self, binding: UDPBinding, socket: FakeSocket) -> None:
    method enable (line 178) | def enable(self) -> None:
    method send_packet (line 182) | def send_packet(self, packet: UDPPacket) -> None:
    method deliver_packet (line 188) | def deliver_packet(self, packet: UDPPacket) -> None:
  class FakeSocket (line 198) | class FakeSocket(trio.socket.SocketType, metaclass=NoPublicConstructor):
    method __init__ (line 199) | def __init__(
    method type (line 232) | def type(self) -> SocketKind:
    method family (line 236) | def family(self) -> AddressFamily:
    method proto (line 240) | def proto(self) -> int:
    method _check_closed (line 243) | def _check_closed(self) -> None:
    method close (line 247) | def close(self) -> None:
    method _resolve_address_nocp (line 255) | async def _resolve_address_nocp(
    method _deliver_packet (line 270) | def _deliver_packet(self, packet: UDPPacket) -> None:
    method bind (line 279) | async def bind(self, addr: object) -> None:
    method connect (line 300) | async def connect(self, peer: object) -> NoReturn:
    method _sendmsg (line 303) | async def _sendmsg(
    method _recvmsg_into (line 347) | async def _recvmsg_into(
    method getsockname (line 392) | def getsockname(self) -> tuple[str, int] | tuple[str, int, int, int]:
    method getpeername (line 403) | def getpeername(self) -> tuple[str, int] | tuple[str, int, int, int]:
    method getsockopt (line 419) | def getsockopt(self, /, level: int, optname: int) -> int: ...
    method getsockopt (line 422) | def getsockopt(self, /, level: int, optname: int, buflen: int) -> byte...
    method getsockopt (line 424) | def getsockopt(
    method setsockopt (line 435) | def setsockopt(self, /, level: int, optname: int, value: int | Buffer)...
    method setsockopt (line 438) | def setsockopt(
    method setsockopt (line 447) | def setsockopt(
    method __enter__ (line 469) | def __enter__(self) -> Self:
    method __exit__ (line 472) | def __exit__(
    method send (line 480) | async def send(self, data: Buffer, flags: int = 0) -> int:
    method sendto (line 485) | async def sendto(
    method sendto (line 493) | async def sendto(
    method sendto (line 500) | async def sendto(  # type: ignore[explicit-any]
    method recv (line 516) | async def recv(self, bufsize: int, flags: int = 0) -> bytes:
    method recv_into (line 520) | async def recv_into(self, buf: Buffer, nbytes: int = 0, flags: int = 0...
    method recvfrom (line 524) | async def recvfrom(
    method recvfrom_into (line 532) | async def recvfrom_into(
    method _recvmsg (line 547) | async def _recvmsg(
    method fileno (line 566) | def fileno(self) -> int:
    method detach (line 569) | def detach(self) -> int:
    method get_inheritable (line 572) | def get_inheritable(self) -> bool:
    method set_inheritable (line 575) | def set_inheritable(self, inheritable: bool) -> None:
    method share (line 583) | def share(self, process_id: int) -> bytes:

FILE: src/trio/testing/_memory_streams.py
  class _UnboundedByteQueue (line 23) | class _UnboundedByteQueue:
    method __init__ (line 24) | def __init__(self) -> None:
    method close (line 36) | def close(self) -> None:
    method close_and_wipe (line 40) | def close_and_wipe(self) -> None:
    method put (line 44) | def put(self, data: bytes | bytearray | memoryview) -> None:
    method _check_max_bytes (line 50) | def _check_max_bytes(self, max_bytes: int | None) -> None:
    method _get_impl (line 57) | def _get_impl(self, max_bytes: int | None) -> bytearray:
    method get_nowait (line 69) | def get_nowait(self, max_bytes: int | None = None) -> bytearray:
    method get (line 76) | async def get(self, max_bytes: int | None = None) -> bytearray:
  class MemorySendStream (line 87) | class MemorySendStream(SendStream):
    method __init__ (line 108) | def __init__(
    method send_all (line 122) | async def send_all(self, data: bytes | bytearray | memoryview) -> None:
    method wait_send_all_might_not_block (line 136) | async def wait_send_all_might_not_block(self) -> None:
    method close (line 151) | def close(self) -> None:
    method aclose (line 168) | async def aclose(self) -> None:
    method get_data (line 173) | async def get_data(self, max_bytes: int | None = None) -> bytearray:
    method get_data_nowait (line 189) | def get_data_nowait(self, max_bytes: int | None = None) -> bytearray:
  class MemoryReceiveStream (line 202) | class MemoryReceiveStream(ReceiveStream):
    method __init__ (line 219) | def __init__(
    method receive_some (line 232) | async def receive_some(self, max_bytes: int | None = None) -> bytearray:
    method close (line 255) | def close(self) -> None:
    method aclose (line 265) | async def aclose(self) -> None:
    method put_data (line 270) | def put_data(self, data: bytes | bytearray | memoryview) -> None:
    method put_eof (line 274) | def put_eof(self) -> None:
  function memory_stream_pump (line 288) | def memory_stream_pump(
  function memory_stream_one_way_pair (line 326) | def memory_stream_one_way_pair() -> tuple[MemorySendStream, MemoryReceiv...
  function _make_stapled_pair (line 365) | def _make_stapled_pair(
  function memory_stream_pair (line 378) | def memory_stream_pair() -> tuple[
  class _LockstepByteQueue (line 463) | class _LockstepByteQueue:
    method __init__ (line 464) | def __init__(self) -> None:
    method _something_happened (line 477) | def _something_happened(self) -> None:
    method _wait_for (line 482) | async def _wait_for(self, fn: Callable[[], bool]) -> None:
    method close_sender (line 491) | def close_sender(self) -> None:
    method close_receiver (line 495) | def close_receiver(self) -> None:
    method send_all (line 499) | async def send_all(self, data: bytes | bytearray | memoryview) -> None:
    method wait_send_all_might_not_block (line 514) | async def wait_send_all_might_not_block(self) -> None:
    method receive_some (line 525) | async def receive_some(self, max_bytes: int | None = None) -> bytes | ...
  class _LockstepSendStream (line 557) | class _LockstepSendStream(SendStream):
    method __init__ (line 558) | def __init__(self, lbq: _LockstepByteQueue) -> None:
    method close (line 561) | def close(self) -> None:
    method aclose (line 564) | async def aclose(self) -> None:
    method send_all (line 568) | async def send_all(self, data: bytes | bytearray | memoryview) -> None:
    method wait_send_all_might_not_block (line 571) | async def wait_send_all_might_not_block(self) -> None:
  class _LockstepReceiveStream (line 575) | class _LockstepReceiveStream(ReceiveStream):
    method __init__ (line 576) | def __init__(self, lbq: _LockstepByteQueue) -> None:
    method close (line 579) | def close(self) -> None:
    method aclose (line 582) | async def aclose(self) -> None:
    method receive_some (line 586) | async def receive_some(self, max_bytes: int | None = None) -> bytes | ...
  function lockstep_stream_one_way_pair (line 590) | def lockstep_stream_one_way_pair() -> tuple[SendStream, ReceiveStream]:
  function lockstep_stream_pair (line 617) | def lockstep_stream_pair() -> tuple[

FILE: src/trio/testing/_network.py
  function open_stream_to_socket_listener (line 5) | async def open_stream_to_socket_listener(

FILE: src/trio/testing/_raises_group.py
  class _ExceptionInfo (line 47) | class _ExceptionInfo(Generic[MatchE]):
    method __init__ (line 52) | def __init__(
    method fill_unfilled (line 58) | def fill_unfilled(
    method for_later (line 67) | def for_later(cls) -> _ExceptionInfo[MatchE]:
    method type (line 73) | def type(self) -> type[MatchE]:
    method value (line 81) | def value(self) -> MatchE:
    method tb (line 89) | def tb(self) -> types.TracebackType:
    method exconly (line 96) | def exconly(self, tryshort: bool = False) -> str:
    method errisinstance (line 101) | def errisinstance(
    method getrepr (line 109) | def getrepr(
  function _stringify_exception (line 140) | def _stringify_exception(exc: BaseException) -> str:
  function _match_pattern (line 153) | def _match_pattern(match: Pattern[str]) -> str | Pattern[str]:
  function repr_callable (line 158) | def repr_callable(fun: Callable[[BaseExcT_1], bool]) -> str:
  function _exception_type_name (line 166) | def _exception_type_name(e: type[BaseException]) -> str:
  function _check_raw_type (line 170) | def _check_raw_type(
  class AbstractMatcher (line 191) | class AbstractMatcher(ABC, Generic[BaseExcT_co]):
    method __init__ (line 194) | def __init__(
    method fail_reason (line 210) | def fail_reason(self) -> str | None:
    method _check_check (line 217) | def _check_check(
    method _check_match (line 231) | def _check_match(self, e: BaseException) -> bool:
    method matches (line 251) | def matches(
  class Matcher (line 260) | class Matcher(AbstractMatcher[MatchE]):
    method __init__ (line 280) | def __init__(
    method __init__ (line 288) | def __init__(
    method __init__ (line 297) | def __init__(self, *, check: Callable[[BaseException], bool]) -> None:...
    method __init__ (line 299) | def __init__(
    method matches (line 314) | def matches(
    method __repr__ (line 344) | def __repr__(self) -> str:
    method _check_type (line 357) | def _check_type(self, exception: BaseException) -> TypeGuard[MatchE]:
  class RaisesGroup (line 363) | class RaisesGroup(AbstractMatcher[BaseExceptionGroup[BaseExcT_co]]):
    method __init__ (line 422) | def __init__(
    method __init__ (line 432) | def __init__(
    method __init__ (line 447) | def __init__(
    method __init__ (line 456) | def __init__(
    method __init__ (line 465) | def __init__(
    method __init__ (line 477) | def __init__(
    method __init__ (line 486) | def __init__(
    method __init__ (line 497) | def __init__(
    method __init__ (line 513) | def __init__(
    method __enter__ (line 600) | def __enter__(
    method __enter__ (line 604) | def __enter__(
    method __enter__ (line 608) | def __enter__(self) -> ExceptionInfo[BaseExceptionGroup[BaseException]]:
    method __repr__ (line 614) | def __repr__(self) -> str:
    method _unroll_exceptions (line 630) | def _unroll_exceptions(
    method matches (line 645) | def matches(
    method matches (line 650) | def matches(
    method matches (line 655) | def matches(
    method _check_expected (line 755) | def _check_expected(
    method _repr_expected (line 774) | def _repr_expected(e: type[BaseException] | AbstractMatcher[BaseExcept...
    method _check_exceptions (line 782) | def _check_exceptions(
    method _check_exceptions (line 788) | def _check_exceptions(
    method _check_exceptions (line 794) | def _check_exceptions(
    method __exit__ (line 913) | def __exit__(
    method expected_type (line 945) | def expected_type(self) -> str:
  class NotChecked (line 961) | class NotChecked: ...
  class ResultHolder (line 964) | class ResultHolder:
    method __init__ (line 965) | def __init__(
    method set_result (line 976) | def set_result(self, expected: int, actual: int, result: str | None) -...
    method get_result (line 979) | def get_result(self, expected: int, actual: int) -> str | None:
    method has_result (line 985) | def has_result(self, expected: int, actual: int) -> bool:
    method no_match_for_expected (line 988) | def no_match_for_expected(self, expected: list[int]) -> bool:
    method no_match_for_actual (line 996) | def no_match_for_actual(self, actual: list[int]) -> bool:
  function possible_match (line 1005) | def possible_match(results: ResultHolder, used: set[int] | None = None) ...

FILE: src/trio/testing/_sequencer.py
  class Sequencer (line 17) | class Sequencer:
    method __call__ (line 65) | async def __call__(self, position: int) -> AsyncIterator[None]:

FILE: src/trio/testing/_trio_test.py
  function trio_test (line 20) | def trio_test(fn: Callable[ArgsT, Awaitable[RetT]]) -> Callable[ArgsT, R...

FILE: tests/_trio_check_attrs_aliases.py
  function field (line 13) | def field(**kwargs: Any) -> Any:
Condensed preview — 219 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,369K chars).
[
  {
    "path": ".builds/alpine.yml",
    "chars": 444,
    "preview": "image: alpine/latest\npackages:\n  - curl\n  - gcc\n  - libffi-dev\n  - musl-dev\n  - openssl-dev\n  - python3-dev\n  # required"
  },
  {
    "path": ".builds/fedora.yml",
    "chars": 348,
    "preview": "image: fedora/rawhide\npackages:\n  - python3-devel\n  - python3-pip\nsources:\n  - https://github.com/python-trio/trio\ntasks"
  },
  {
    "path": ".builds/freebsd.yml",
    "chars": 451,
    "preview": "image: freebsd/latest\npackages:\n  - curl\n  - python39\n  - py39-sqlite3\n  - rust  # required to build cryptography\nsource"
  },
  {
    "path": ".codecov.yml",
    "chars": 1028,
    "preview": "# -- repository yaml --\n\n# Explicitly wait for all jobs to finish, as wait_for_ci prematurely triggers.\n# See https://gi"
  },
  {
    "path": ".git-blame-ignore-revs",
    "chars": 152,
    "preview": "# sorting all imports with isort\n933f77b96f0092e1baab4474a9208fc2e379aa32\n# enabling ruff's flake8-commas rule\nb25c02a94"
  },
  {
    "path": ".gitattributes",
    "chars": 216,
    "preview": "# For files generated by trio/_tools/gen_exports.py or trio/_tools/windows_ffi_build.py\ntrio/_core/_generated*    lingui"
  },
  {
    "path": ".github/workflows/autodeps.yml",
    "chars": 2879,
    "preview": "name: Autodeps\n\non:\n  workflow_dispatch:\n  schedule:\n    - cron:  '0 0 1 * *'\n\njobs:\n  Autodeps:\n    if: github.reposito"
  },
  {
    "path": ".github/workflows/check-newsfragment.yml",
    "chars": 642,
    "preview": "name: Check newsfragment\n\npermissions: {}\n\non:\n  pull_request:\n    types: [labeled, unlabeled, opened, synchronize]\n    "
  },
  {
    "path": ".github/workflows/ci.yml",
    "chars": 15922,
    "preview": "name: CI\n\npermissions: {}\n\non:\n  push:\n    branches-ignore:\n      # these branches always have another event associated\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "chars": 1061,
    "preview": "on:\n  push:\n    tags:\n      - v*\n\npermissions: {}\n\n# a lot of code taken from https://github.com/pypa/cibuildwheel/blob/"
  },
  {
    "path": ".gitignore",
    "chars": 932,
    "preview": "# generated by cythonize\ntests/cython/test_cython.c\n\n# In case somebody wants to restore the directory for local testing"
  },
  {
    "path": ".pre-commit-config.yaml",
    "chars": 3066,
    "preview": "ci:\n  autofix_prs: true\n  autoupdate_schedule: weekly\n  submodules: false\n  # pip-compile requires internet, regenerate-"
  },
  {
    "path": ".readthedocs.yml",
    "chars": 308,
    "preview": "# https://docs.readthedocs.io/en/latest/config-file/index.html\nversion: 2\n\nformats:\n  - htmlzip\n  - epub\n\nbuild:\n  os: \""
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "chars": 98,
    "preview": "For the Trio code of conduct, see:\n    https://trio.readthedocs.io/en/latest/code-of-conduct.html\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "chars": 98,
    "preview": "For the Trio contributing guide, see:\n    https://trio.readthedocs.io/en/latest/contributing.html\n"
  },
  {
    "path": "LICENSE",
    "chars": 190,
    "preview": "This software is made available under the terms of *either* of the\nlicenses found in LICENSE.APACHE2 or LICENSE.MIT. Con"
  },
  {
    "path": "LICENSE.APACHE2",
    "chars": 11358,
    "preview": "\n                                 Apache License\n                           Version 2.0, January 2004\n                  "
  },
  {
    "path": "LICENSE.MIT",
    "chars": 1091,
    "preview": "Copyright Contributors to the Trio project.\n\nThe MIT License (MIT)\n\nPermission is hereby granted, free of charge, to any"
  },
  {
    "path": "MANIFEST.in",
    "chars": 413,
    "preview": "include .codecov.yml\ninclude check.sh\ninclude ci.sh\ninclude LICENSE LICENSE.MIT LICENSE.APACHE2\ninclude README.rst\ninclu"
  },
  {
    "path": "README.rst",
    "chars": 6802,
    "preview": ".. image:: https://img.shields.io/badge/chat-join%20now-blue.svg\n   :target: https://gitter.im/python-trio/general\n   :a"
  },
  {
    "path": "ci.sh",
    "chars": 5833,
    "preview": "#!/bin/bash\n\nset -ex -o pipefail\n\n# disable warnings about pyright being out of date\n# used in test_exports and in check"
  },
  {
    "path": "docs/Makefile",
    "chars": 606,
    "preview": "# Minimal makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS    =\nSPHI"
  },
  {
    "path": "docs/make.bat",
    "chars": 812,
    "preview": "@ECHO OFF\r\n\r\npushd %~dp0\r\n\r\nREM Command file for Sphinx documentation\r\n\r\nif \"%SPHINXBUILD%\" == \"\" (\r\n\tset SPHINXBUILD=sp"
  },
  {
    "path": "docs/notes.txt",
    "chars": 647,
    "preview": "it's possible from extension/configuration modules to get sphinx to\nknow about new roles and even new autodoc types.\n\nSe"
  },
  {
    "path": "docs/source/_static/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "docs/source/_static/styles.css",
    "chars": 2939,
    "preview": "/* Make .. deprecation:: blocks visible\n * (by default they're entirely unstyled)\n */\n.deprecated {\n    background-color"
  },
  {
    "path": "docs/source/_templates/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "docs/source/_templates/genindex.html",
    "chars": 1249,
    "preview": "{% extends \"!genindex.html\" %}\n\n{# check sphinx/themes/basic/genindex if this snippet has become outdated #}\n\n{% block b"
  },
  {
    "path": "docs/source/_templates/layout.html",
    "chars": 1153,
    "preview": "{#\nhttps://stackoverflow.com/questions/25243482/how-to-add-sphinx-generated-index-to-the-sidebar-when-using-read-the-doc"
  },
  {
    "path": "docs/source/awesome-trio-libraries.rst",
    "chars": 9054,
    "preview": "Awesome Trio Libraries\n======================\n\n.. List of Trio Libraries\n\n   A list of libraries that support Trio, simi"
  },
  {
    "path": "docs/source/code-of-conduct.rst",
    "chars": 10874,
    "preview": ".. _code-of-conduct:\n\nCode of Conduct\n===============\n\nThis code of conduct applies to the Trio project, and all associa"
  },
  {
    "path": "docs/source/conf.py",
    "chars": 16149,
    "preview": "#!/usr/bin/env python3\n#\n# Trio documentation build configuration file, created by\n# sphinx-quickstart on Sat Jan 21 19:"
  },
  {
    "path": "docs/source/contributing.rst",
    "chars": 26043,
    "preview": ".. _contributing:\n\nContributing to Trio and related projects\n=========================================\n\nSo you're intere"
  },
  {
    "path": "docs/source/design.rst",
    "chars": 25367,
    "preview": "Design and internals\n====================\n\n.. currentmodule:: trio\n\nHere we'll discuss Trio's overall design and archite"
  },
  {
    "path": "docs/source/glossary.rst",
    "chars": 449,
    "preview": ":orphan:\n\n.. _glossary:\n\n********\nGlossary\n********\n\n.. glossary::\n\n   asynchronous file object\n       This is an object"
  },
  {
    "path": "docs/source/history.rst",
    "chars": 93957,
    "preview": "Release history\n===============\n\n.. currentmodule:: trio\n\n.. towncrier release notes start\n\ntrio 0.33.0 (2026-02-14)\n---"
  },
  {
    "path": "docs/source/index.rst",
    "chars": 3740,
    "preview": ".. Trio documentation master file, created by\n   sphinx-quickstart on Sat Jan 21 19:11:14 2017.\n   You can adapt this fi"
  },
  {
    "path": "docs/source/local_customization.py",
    "chars": 1004,
    "preview": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nfrom docutils.parsers.rst import directives as dir"
  },
  {
    "path": "docs/source/reference-core/channels-backpressure.py",
    "chars": 928,
    "preview": "# Simulate a producer that generates values 10x faster than the\n# consumer can handle them.\n\nimport trio\nimport math\n\n\na"
  },
  {
    "path": "docs/source/reference-core/channels-mpmc-broken.py",
    "chars": 1067,
    "preview": "# This example usually crashes!\n\nimport trio\nimport random\n\n\nasync def main():\n    async with trio.open_nursery() as nur"
  },
  {
    "path": "docs/source/reference-core/channels-mpmc-fixed.py",
    "chars": 1210,
    "preview": "import trio\nimport random\n\n\nasync def main():\n    async with trio.open_nursery() as nursery:\n        send_channel, recei"
  },
  {
    "path": "docs/source/reference-core/channels-shutdown.py",
    "chars": 570,
    "preview": "import trio\n\n\nasync def main():\n    async with trio.open_nursery() as nursery:\n        send_channel, receive_channel = t"
  },
  {
    "path": "docs/source/reference-core/channels-simple.py",
    "chars": 785,
    "preview": "import trio\n\n\nasync def main():\n    async with trio.open_nursery() as nursery:\n        # Open a channel:\n        send_ch"
  },
  {
    "path": "docs/source/reference-core/contextvar-example.py",
    "chars": 1259,
    "preview": "import random\nimport trio\nimport contextvars\n\nrequest_info = contextvars.ContextVar(\"request_info\")\n\n\n# Example logging "
  },
  {
    "path": "docs/source/reference-core/from-thread-example.py",
    "chars": 1366,
    "preview": "import trio\n\n\ndef thread_fn(receive_from_trio, send_to_trio):\n    while True:\n        # Since we're in a thread, we can'"
  },
  {
    "path": "docs/source/reference-core/thread-contextvars-example.py",
    "chars": 1772,
    "preview": "import contextvars\nimport time\n\nimport trio\n\nrequest_state = contextvars.ContextVar(\"request_state\")\n\n# Blocking functio"
  },
  {
    "path": "docs/source/reference-core.rst",
    "chars": 84611,
    "preview": "Trio's core functionality\n=========================\n\n.. module:: trio\n\n\nEntering Trio\n-------------\n\nIf you want to use "
  },
  {
    "path": "docs/source/reference-io.rst",
    "chars": 33246,
    "preview": ".. currentmodule:: trio\n\nI/O in Trio\n===========\n\n.. _abstract-stream-api:\n\nThe abstract Stream API\n--------------------"
  },
  {
    "path": "docs/source/reference-lowlevel.rst",
    "chars": 43015,
    "preview": "=========================================================\n Introspecting and extending Trio with ``trio.lowlevel``\n====="
  },
  {
    "path": "docs/source/reference-testing/across-realtime.out",
    "chars": 832,
    "preview": "Clock where time passes at 100 years per second:\n\ntask2: sleeping for 5 years\ntask1: sleeping for 1 year\ntask1: woke up;"
  },
  {
    "path": "docs/source/reference-testing/across-realtime.py",
    "chars": 1571,
    "preview": "# across-realtime.py\n\nimport time\nimport trio\nimport trio.testing\n\nYEAR = 365 * 24 * 60 * 60  # seconds\n\n\nasync def task"
  },
  {
    "path": "docs/source/reference-testing.rst",
    "chars": 7496,
    "preview": "Testing made easier with ``trio.testing``\n=========================================\n\n.. module:: trio.testing\n\nThe :mod:"
  },
  {
    "path": "docs/source/releasing.rst",
    "chars": 1491,
    "preview": ".. _releasing:\n\nPreparing a release\n-------------------\n\nThings to do for releasing:\n\n* announce intent to release on gi"
  },
  {
    "path": "docs/source/tutorial/echo-client.py",
    "chars": 1143,
    "preview": "# echo-client.py\n\nimport sys\nimport trio\n\n# arbitrary, but:\n# - must be in between 1024 and 65535\n# - can't be in use by"
  },
  {
    "path": "docs/source/tutorial/echo-server.py",
    "chars": 1631,
    "preview": "# echo-server.py\n\nimport trio\nfrom itertools import count\n\n# Port is arbitrary, but:\n# - must be in between 1024 and 655"
  },
  {
    "path": "docs/source/tutorial/tasks-intro.py",
    "chars": 697,
    "preview": "# tasks-intro.py\n\nimport trio\n\n\nasync def child1():\n    print(\"  child1: started! sleeping now...\")\n    await trio.sleep"
  },
  {
    "path": "docs/source/tutorial/tasks-with-trace.py",
    "chars": 2000,
    "preview": "# tasks-with-trace.py\n\nimport trio\n\n\nasync def child1():\n    print(\"  child1: started! sleeping now...\")\n    await trio."
  },
  {
    "path": "docs/source/tutorial.rst",
    "chars": 48456,
    "preview": "Tutorial\n========\n\n.. The Trio tutorial\n\n   the spiel about what a concurrent library is\n\n   Traditionally Python is a s"
  },
  {
    "path": "docs/source/typevars.py",
    "chars": 3852,
    "preview": "\"\"\"Transform references to typevars to avoid missing reference errors.\n\nSee https://github.com/sphinx-doc/sphinx/issues/"
  },
  {
    "path": "docs-requirements.in",
    "chars": 557,
    "preview": "# RTD is currently installing 1.5.3, which has a bug in :lineno-match: (??)\n# sphinx 5.3 doesn't work with our _NoValue "
  },
  {
    "path": "docs-requirements.txt",
    "chars": 2867,
    "preview": "# This file was autogenerated by uv via the following command:\n#    uv pip compile --universal --python-version=3.11 doc"
  },
  {
    "path": "newsfragments/.gitkeep",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "newsfragments/3261.bugfix.rst",
    "chars": 137,
    "preview": "``Nursery.start()`` now preserves the ``__cause__`` and ``__context__`` of\nexceptions raised before ``task_status.starte"
  },
  {
    "path": "newsfragments/README.rst",
    "chars": 1671,
    "preview": "This directory collects \"newsfragments\": short files that each contain\na snippet of ReST-formatted text that will be add"
  },
  {
    "path": "pyproject.toml",
    "chars": 10405,
    "preview": "[build-system]\n# setuptools v77 adds PEP 639 support\nrequires = [\"setuptools >= 77\"]\nbuild-backend = \"setuptools.build_m"
  },
  {
    "path": "src/trio/__init__.py",
    "chars": 4758,
    "preview": "\"\"\"Trio - A friendly Python library for async concurrency and I/O\"\"\"\n\nfrom __future__ import annotations\n\nfrom typing im"
  },
  {
    "path": "src/trio/__main__.py",
    "chars": 44,
    "preview": "from trio._repl import main\n\nmain(locals())\n"
  },
  {
    "path": "src/trio/_abc.py",
    "chars": 25677,
    "preview": "from __future__ import annotations\n\nimport socket\nfrom abc import ABC, abstractmethod\nfrom typing import TYPE_CHECKING, "
  },
  {
    "path": "src/trio/_channel.py",
    "chars": 23970,
    "preview": "from __future__ import annotations\n\nimport sys\nfrom collections import OrderedDict, deque\nfrom collections.abc import As"
  },
  {
    "path": "src/trio/_core/__init__.py",
    "chars": 2433,
    "preview": "\"\"\"\nThis namespace represents the core functionality that has to be built-in\nand deal with private internal data structu"
  },
  {
    "path": "src/trio/_core/_asyncgens.py",
    "chars": 10680,
    "preview": "from __future__ import annotations\n\nimport logging\nimport sys\nimport warnings\nimport weakref\nfrom typing import TYPE_CHE"
  },
  {
    "path": "src/trio/_core/_concat_tb.py",
    "chars": 877,
    "preview": "from __future__ import annotations\n\nfrom types import TracebackType\n\n\n# this is used for collapsing single-exception Exc"
  },
  {
    "path": "src/trio/_core/_entry_queue.py",
    "chars": 9427,
    "preview": "from __future__ import annotations\n\nimport threading\nfrom collections import deque\nfrom collections.abc import Callable\n"
  },
  {
    "path": "src/trio/_core/_exceptions.py",
    "chars": 5777,
    "preview": "from __future__ import annotations\n\nfrom functools import partial\nfrom typing import TYPE_CHECKING, Literal, TypeAlias\n\n"
  },
  {
    "path": "src/trio/_core/_generated_instrumentation.py",
    "chars": 1627,
    "preview": "# ***********************************************************\n# ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST *"
  },
  {
    "path": "src/trio/_core/_generated_io_epoll.py",
    "chars": 3848,
    "preview": "# ***********************************************************\n# ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST *"
  },
  {
    "path": "src/trio/_core/_generated_io_kqueue.py",
    "chars": 5543,
    "preview": "# ***********************************************************\n# ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST *"
  },
  {
    "path": "src/trio/_core/_generated_io_windows.py",
    "chars": 7489,
    "preview": "# ***********************************************************\n# ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST *"
  },
  {
    "path": "src/trio/_core/_generated_run.py",
    "chars": 10126,
    "preview": "# ***********************************************************\n# ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST *"
  },
  {
    "path": "src/trio/_core/_generated_windows_ffi.py",
    "chars": 4586,
    "preview": "# auto-generated file\nimport _cffi_backend\n\nffi = _cffi_backend.FFI('trio._core._generated_windows_ffi',\n    _version = "
  },
  {
    "path": "src/trio/_core/_instrumentation.py",
    "chars": 3959,
    "preview": "from __future__ import annotations\n\nimport logging\nimport types\nfrom collections import UserDict\nfrom typing import TYPE"
  },
  {
    "path": "src/trio/_core/_io_common.py",
    "chars": 857,
    "preview": "from __future__ import annotations\n\nimport copy\nfrom typing import TYPE_CHECKING\n\nimport outcome\n\nfrom .. import _core\n\n"
  },
  {
    "path": "src/trio/_core/_io_epoll.py",
    "chars": 17803,
    "preview": "from __future__ import annotations\n\nimport contextlib\nimport select\nimport sys\nfrom collections import defaultdict\nfrom "
  },
  {
    "path": "src/trio/_core/_io_kqueue.py",
    "chars": 11547,
    "preview": "from __future__ import annotations\n\nimport errno\nimport select\nimport sys\nfrom contextlib import contextmanager\nfrom typ"
  },
  {
    "path": "src/trio/_core/_io_windows.py",
    "chars": 43872,
    "preview": "from __future__ import annotations\n\nimport enum\nimport itertools\nimport socket\nimport sys\nfrom contextlib import context"
  },
  {
    "path": "src/trio/_core/_ki.py",
    "chars": 9070,
    "preview": "from __future__ import annotations\n\nimport signal\nimport sys\nimport weakref\nfrom typing import TYPE_CHECKING, Generic, P"
  },
  {
    "path": "src/trio/_core/_local.py",
    "chars": 3212,
    "preview": "from __future__ import annotations\n\nfrom typing import Generic, TypeVar, cast\n\n# Runvar implementations\nimport attrs\n\nfr"
  },
  {
    "path": "src/trio/_core/_mock_clock.py",
    "chars": 6316,
    "preview": "import time\nfrom math import inf\n\nfrom .. import _core\nfrom .._abc import Clock\nfrom .._util import final\nfrom ._run imp"
  },
  {
    "path": "src/trio/_core/_parking_lot.py",
    "chars": 11970,
    "preview": "# ParkingLot provides an abstraction for a fair waitqueue with cancellation\n# and requeuing support. Inspiration:\n#\n#   "
  },
  {
    "path": "src/trio/_core/_run.py",
    "chars": 129577,
    "preview": "from __future__ import annotations\n\nimport enum\nimport functools\nimport gc\nimport itertools\nimport random\nimport select\n"
  },
  {
    "path": "src/trio/_core/_run_context.py",
    "chars": 261,
    "preview": "from __future__ import annotations\n\nimport threading\nfrom typing import TYPE_CHECKING, Final\n\nif TYPE_CHECKING:\n    from"
  },
  {
    "path": "src/trio/_core/_tests/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "src/trio/_core/_tests/test_asyncgen.py",
    "chars": 11695,
    "preview": "from __future__ import annotations\n\nimport contextlib\nimport sys\nimport weakref\nfrom math import inf\nfrom types import A"
  },
  {
    "path": "src/trio/_core/_tests/test_cancelled.py",
    "chars": 7604,
    "preview": "import pickle\nimport re\nfrom math import inf\n\nimport pytest\n\nimport trio\nfrom trio import Cancelled\nfrom trio.lowlevel i"
  },
  {
    "path": "src/trio/_core/_tests/test_exceptiongroup_gc.py",
    "chars": 2845,
    "preview": "from __future__ import annotations\n\nimport gc\nimport sys\nfrom traceback import extract_tb\nfrom typing import TYPE_CHECKI"
  },
  {
    "path": "src/trio/_core/_tests/test_guest_mode.py",
    "chars": 25672,
    "preview": "from __future__ import annotations\n\nimport asyncio\nimport contextlib\nimport queue\nimport signal\nimport socket\nimport sys"
  },
  {
    "path": "src/trio/_core/_tests/test_instrumentation.py",
    "chars": 9681,
    "preview": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING, NoReturn\n\nimport attrs\nimport pytest\n\nfrom ... imp"
  },
  {
    "path": "src/trio/_core/_tests/test_io.py",
    "chars": 17673,
    "preview": "from __future__ import annotations\n\nimport random\nimport select\nimport socket as stdlib_socket\nimport sys\nfrom collectio"
  },
  {
    "path": "src/trio/_core/_tests/test_ki.py",
    "chars": 21293,
    "preview": "from __future__ import annotations\n\nimport contextlib\nimport inspect\nimport signal\nimport sys\nimport threading\nimport we"
  },
  {
    "path": "src/trio/_core/_tests/test_local.py",
    "chars": 2891,
    "preview": "import pytest\n\nfrom trio import run\nfrom trio.lowlevel import RunVar, RunVarToken\n\nfrom ... import _core\n\n\n# scary runva"
  },
  {
    "path": "src/trio/_core/_tests/test_mock_clock.py",
    "chars": 5827,
    "preview": "import time\nfrom math import inf\n\nimport pytest\n\nfrom trio import sleep\n\nfrom ... import _core\nfrom .. import wait_all_t"
  },
  {
    "path": "src/trio/_core/_tests/test_parking_lot.py",
    "chars": 12023,
    "preview": "from __future__ import annotations\n\nimport re\nfrom typing import TypeVar\n\nimport pytest\n\nimport trio\nfrom trio.lowlevel "
  },
  {
    "path": "src/trio/_core/_tests/test_run.py",
    "chars": 104912,
    "preview": "from __future__ import annotations\n\nimport contextvars\nimport functools\nimport gc\nimport sys\nimport threading\nimport tim"
  },
  {
    "path": "src/trio/_core/_tests/test_thread_cache.py",
    "chars": 7001,
    "preview": "from __future__ import annotations\n\nimport os\nimport threading\nimport time\nfrom contextlib import contextmanager\nfrom qu"
  },
  {
    "path": "src/trio/_core/_tests/test_tutil.py",
    "chars": 459,
    "preview": "import pytest\n\nfrom .tutil import check_sequence_matches\n\n\ndef test_check_sequence_matches() -> None:\n    check_sequence"
  },
  {
    "path": "src/trio/_core/_tests/test_unbounded_queue.py",
    "chars": 4323,
    "preview": "from __future__ import annotations\n\nimport itertools\n\nimport pytest\n\nfrom ... import _core\nfrom ...testing import assert"
  },
  {
    "path": "src/trio/_core/_tests/test_windows.py",
    "chars": 10628,
    "preview": "from __future__ import annotations\n\nimport os\nimport sys\nimport tempfile\nfrom contextlib import contextmanager\nfrom typi"
  },
  {
    "path": "src/trio/_core/_tests/tutil.py",
    "chars": 4026,
    "preview": "# Utilities for testing\nfrom __future__ import annotations\n\nimport asyncio\nimport gc\nimport os\nimport socket as stdlib_s"
  },
  {
    "path": "src/trio/_core/_tests/type_tests/nursery_start.py",
    "chars": 2094,
    "preview": "\"\"\"Test variadic generic typing for Nursery.start[_soon]().\"\"\"\n\nfrom typing import TYPE_CHECKING\n\nfrom trio import TASK_"
  },
  {
    "path": "src/trio/_core/_tests/type_tests/run.py",
    "chars": 1121,
    "preview": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING, overload\n\nimport trio\nfrom typing_extensions impor"
  },
  {
    "path": "src/trio/_core/_thread_cache.py",
    "chars": 11984,
    "preview": "from __future__ import annotations\n\nimport ctypes\nimport ctypes.util\nimport os\nimport sys\nimport traceback\nfrom functool"
  },
  {
    "path": "src/trio/_core/_traps.py",
    "chars": 12577,
    "preview": "\"\"\"These are the only functions that ever yield back to the task runner.\"\"\"\n\nfrom __future__ import annotations\n\nimport "
  },
  {
    "path": "src/trio/_core/_unbounded_queue.py",
    "chars": 5026,
    "preview": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING, Generic, TypeVar\n\nimport attrs\n\nfrom .. import _co"
  },
  {
    "path": "src/trio/_core/_wakeup_socketpair.py",
    "chars": 2882,
    "preview": "from __future__ import annotations\n\nimport contextlib\nimport signal\nimport socket\nimport warnings\n\nfrom .. import _core\n"
  },
  {
    "path": "src/trio/_core/_windows_cffi.py",
    "chars": 8750,
    "preview": "from __future__ import annotations\n\nimport enum\nfrom typing import TYPE_CHECKING, NewType, NoReturn, Protocol, TypeAlias"
  },
  {
    "path": "src/trio/_deprecate.py",
    "chars": 5489,
    "preview": "from __future__ import annotations\n\nimport sys\nimport warnings\nfrom functools import wraps\nfrom typing import TYPE_CHECK"
  },
  {
    "path": "src/trio/_dtls.py",
    "chars": 54095,
    "preview": "# Implementation of DTLS 1.2, using pyopenssl\n# https://datatracker.ietf.org/doc/html/rfc6347\n#\n# OpenSSL's APIs for DTL"
  },
  {
    "path": "src/trio/_file_io.py",
    "chars": 15607,
    "preview": "from __future__ import annotations\n\nimport io\nfrom collections.abc import Callable, Iterable\nfrom functools import parti"
  },
  {
    "path": "src/trio/_highlevel_generic.py",
    "chars": 4734,
    "preview": "from __future__ import annotations\n\nfrom typing import Generic, TypeGuard, TypeVar\n\nimport attrs\n\nimport trio\nfrom trio."
  },
  {
    "path": "src/trio/_highlevel_open_tcp_listeners.py",
    "chars": 9986,
    "preview": "from __future__ import annotations\n\nimport errno\nimport sys\nfrom typing import TYPE_CHECKING\n\nimport trio\nfrom trio impo"
  },
  {
    "path": "src/trio/_highlevel_open_tcp_stream.py",
    "chars": 18471,
    "preview": "from __future__ import annotations\n\nimport sys\nfrom contextlib import contextmanager, suppress\nfrom typing import TYPE_C"
  },
  {
    "path": "src/trio/_highlevel_open_unix_stream.py",
    "chars": 1625,
    "preview": "from __future__ import annotations\n\nimport os\nfrom contextlib import contextmanager\nfrom typing import TYPE_CHECKING, Pr"
  },
  {
    "path": "src/trio/_highlevel_serve_listeners.py",
    "chars": 5180,
    "preview": "from __future__ import annotations\n\nimport errno\nimport logging\nimport os\nfrom collections.abc import Awaitable, Callabl"
  },
  {
    "path": "src/trio/_highlevel_socket.py",
    "chars": 16070,
    "preview": "# \"High-level\" networking interface\nfrom __future__ import annotations\n\nimport errno\nfrom contextlib import contextmanag"
  },
  {
    "path": "src/trio/_highlevel_ssl_helpers.py",
    "chars": 6531,
    "preview": "from __future__ import annotations\n\nimport ssl\nfrom typing import TYPE_CHECKING, NoReturn, TypeVar\n\nimport trio\n\nfrom ._"
  },
  {
    "path": "src/trio/_path.py",
    "chars": 9515,
    "preview": "from __future__ import annotations\n\nimport os\nimport pathlib\nimport sys\nfrom functools import partial, update_wrapper\nfr"
  },
  {
    "path": "src/trio/_repl.py",
    "chars": 5704,
    "preview": "from __future__ import annotations\n\nimport ast\nimport contextlib\nimport inspect\nimport sys\nimport warnings\nfrom code imp"
  },
  {
    "path": "src/trio/_signals.py",
    "chars": 7187,
    "preview": "from __future__ import annotations\n\nimport signal\nfrom collections import OrderedDict\nfrom contextlib import contextmana"
  },
  {
    "path": "src/trio/_socket.py",
    "chars": 45448,
    "preview": "from __future__ import annotations\n\nimport os\nimport select\nimport socket as _stdlib_socket\nimport sys\nfrom operator imp"
  },
  {
    "path": "src/trio/_ssl.py",
    "chars": 45821,
    "preview": "from __future__ import annotations\n\nimport contextlib\nimport operator as _operator\nimport ssl as _stdlib_ssl\nfrom enum i"
  },
  {
    "path": "src/trio/_subprocess.py",
    "chars": 53126,
    "preview": "from __future__ import annotations\n\nimport contextlib\nimport os\nimport subprocess\nimport sys\nimport warnings\nfrom contex"
  },
  {
    "path": "src/trio/_subprocess_platform/__init__.py",
    "chars": 4699,
    "preview": "# Platform-specific subprocess bits'n'pieces.\nfrom __future__ import annotations\n\nimport os\nimport sys\nfrom typing impor"
  },
  {
    "path": "src/trio/_subprocess_platform/kqueue.py",
    "chars": 1847,
    "preview": "from __future__ import annotations\n\nimport select\nimport sys\nfrom typing import TYPE_CHECKING\n\nfrom .. import _core, _su"
  },
  {
    "path": "src/trio/_subprocess_platform/waitid.py",
    "chars": 3888,
    "preview": "import errno\nimport math\nimport os\nimport sys\nfrom typing import TYPE_CHECKING\n\nfrom .. import _core, _subprocess\nfrom ."
  },
  {
    "path": "src/trio/_subprocess_platform/windows.py",
    "chars": 365,
    "preview": "from typing import TYPE_CHECKING\n\nfrom .._wait_for_object import WaitForSingleObject\n\nif TYPE_CHECKING:\n    from .. impo"
  },
  {
    "path": "src/trio/_sync.py",
    "chars": 32256,
    "preview": "from __future__ import annotations\n\nimport math\nfrom typing import TYPE_CHECKING, Literal, Protocol, TypeVar\n\nimport att"
  },
  {
    "path": "src/trio/_tests/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "src/trio/_tests/_check_type_completeness.json",
    "chars": 3406,
    "preview": "{\n    \"Darwin\": [\n        \"No docstring found for function \\\"trio._unix_pipes.FdStream.send_all\\\"\",\n        \"No docstrin"
  },
  {
    "path": "src/trio/_tests/check_type_completeness.py",
    "chars": 9847,
    "preview": "#!/usr/bin/env python3\n\"\"\"This is a file that wraps calls to `pyright --verifytypes`, achieving two things:\n1. give an e"
  },
  {
    "path": "src/trio/_tests/module_with_deprecations.py",
    "chars": 447,
    "preview": "regular = \"hi\"\n\nimport sys\n\nfrom .. import _deprecate\n\n_deprecate.deprecate_attributes(\n    __name__,\n    {\n        \"dep"
  },
  {
    "path": "src/trio/_tests/pytest_plugin.py",
    "chars": 1581,
    "preview": "from __future__ import annotations\n\nimport inspect\nfrom typing import NoReturn\n\nimport pytest\n\nfrom ..testing import Moc"
  },
  {
    "path": "src/trio/_tests/test_abc.py",
    "chars": 2034,
    "preview": "from __future__ import annotations\n\nimport attrs\nimport pytest\n\nfrom .. import abc as tabc\nfrom ..lowlevel import Task\n\n"
  },
  {
    "path": "src/trio/_tests/test_channel.py",
    "chars": 23188,
    "preview": "from __future__ import annotations\n\nimport sys\nfrom typing import TYPE_CHECKING\n\nimport pytest\n\nimport trio\nfrom trio im"
  },
  {
    "path": "src/trio/_tests/test_contextvars.py",
    "chars": 1534,
    "preview": "from __future__ import annotations\n\nimport contextvars\n\nfrom .. import _core\n\ntrio_testing_contextvar: contextvars.Conte"
  },
  {
    "path": "src/trio/_tests/test_deprecate.py",
    "chars": 8324,
    "preview": "from __future__ import annotations\n\nimport inspect\nimport warnings\nfrom types import ModuleType\n\nimport pytest\n\nfrom .._"
  },
  {
    "path": "src/trio/_tests/test_deprecate_strict_exception_groups_false.py",
    "chars": 1874,
    "preview": "from collections.abc import Awaitable, Callable\n\nimport pytest\n\nimport trio\n\n\nasync def test_deprecation_warning_open_nu"
  },
  {
    "path": "src/trio/_tests/test_dtls.py",
    "chars": 36040,
    "preview": "from __future__ import annotations\n\nimport random\nfrom contextlib import asynccontextmanager\nfrom itertools import count"
  },
  {
    "path": "src/trio/_tests/test_exports.py",
    "chars": 23088,
    "preview": "from __future__ import annotations  # isort: split\n\nimport __future__  # Regular import, not special!\n\nimport enum\nimpor"
  },
  {
    "path": "src/trio/_tests/test_fakenet.py",
    "chars": 9794,
    "preview": "import errno\nimport re\nimport socket\nimport sys\n\nimport pytest\n\nimport trio\nfrom trio.testing._fake_net import FakeNet\n\n"
  },
  {
    "path": "src/trio/_tests/test_file_io.py",
    "chars": 7716,
    "preview": "from __future__ import annotations\n\nimport importlib\nimport io\nimport os\nimport re\nfrom typing import TYPE_CHECKING\nfrom"
  },
  {
    "path": "src/trio/_tests/test_highlevel_generic.py",
    "chars": 3036,
    "preview": "from __future__ import annotations\n\nfrom typing import NoReturn\n\nimport attrs\nimport pytest\n\nfrom .._highlevel_generic i"
  },
  {
    "path": "src/trio/_tests/test_highlevel_open_tcp_listeners.py",
    "chars": 13545,
    "preview": "from __future__ import annotations\n\nimport errno\nimport socket as stdlib_socket\nimport sys\nfrom socket import AddressFam"
  },
  {
    "path": "src/trio/_tests/test_highlevel_open_tcp_stream.py",
    "chars": 22538,
    "preview": "from __future__ import annotations\n\nimport socket\nimport sys\nfrom socket import AddressFamily, SocketKind\nfrom typing im"
  },
  {
    "path": "src/trio/_tests/test_highlevel_open_unix_stream.py",
    "chars": 2445,
    "preview": "import os\nimport socket\nimport sys\nimport tempfile\nfrom typing import TYPE_CHECKING\n\nimport pytest\n\nfrom trio import Pat"
  },
  {
    "path": "src/trio/_tests/test_highlevel_serve_listeners.py",
    "chars": 6102,
    "preview": "from __future__ import annotations\n\nimport errno\nfrom functools import partial\nfrom typing import TYPE_CHECKING, NoRetur"
  },
  {
    "path": "src/trio/_tests/test_highlevel_socket.py",
    "chars": 11048,
    "preview": "from __future__ import annotations\n\nimport errno\nimport socket as stdlib_socket\nimport sys\nfrom typing import TYPE_CHECK"
  },
  {
    "path": "src/trio/_tests/test_highlevel_ssl_helpers.py",
    "chars": 5793,
    "preview": "from __future__ import annotations\n\nfrom functools import partial\nfrom typing import TYPE_CHECKING, NoReturn, cast\n\nimpo"
  },
  {
    "path": "src/trio/_tests/test_path.py",
    "chars": 7846,
    "preview": "from __future__ import annotations\n\nimport os\nimport pathlib\nfrom typing import TYPE_CHECKING\n\nimport pytest\n\nimport tri"
  },
  {
    "path": "src/trio/_tests/test_repl.py",
    "chars": 13967,
    "preview": "from __future__ import annotations\n\nimport os\nimport pathlib\nimport signal\nimport subprocess\nimport sys\nfrom functools i"
  },
  {
    "path": "src/trio/_tests/test_scheduler_determinism.py",
    "chars": 1320,
    "preview": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nimport trio\n\nif TYPE_CHECKING:\n    import pytest\n\n"
  },
  {
    "path": "src/trio/_tests/test_signals.py",
    "chars": 7472,
    "preview": "from __future__ import annotations\n\nimport signal\nfrom typing import TYPE_CHECKING, NoReturn\n\nimport pytest\n\nimport trio"
  },
  {
    "path": "src/trio/_tests/test_socket.py",
    "chars": 44672,
    "preview": "from __future__ import annotations\n\nimport errno\nimport inspect\nimport os\nimport socket as stdlib_socket\nimport sys\nimpo"
  },
  {
    "path": "src/trio/_tests/test_ssl.py",
    "chars": 51018,
    "preview": "from __future__ import annotations\n\nimport os\nimport socket as stdlib_socket\nimport ssl\nimport sys\nimport threading\nfrom"
  },
  {
    "path": "src/trio/_tests/test_subprocess.py",
    "chars": 26668,
    "preview": "from __future__ import annotations\n\nimport gc\nimport os\nimport random\nimport signal\nimport subprocess\nimport sys\nfrom co"
  },
  {
    "path": "src/trio/_tests/test_sync.py",
    "chars": 21765,
    "preview": "from __future__ import annotations\n\nimport re\nimport weakref\nfrom collections.abc import Callable\nfrom typing import Typ"
  },
  {
    "path": "src/trio/_tests/test_testing.py",
    "chars": 20772,
    "preview": "from __future__ import annotations\n\n# XX this should get broken up, like testing.py did\nimport tempfile\nfrom typing impo"
  },
  {
    "path": "src/trio/_tests/test_testing_raisesgroup.py",
    "chars": 46719,
    "preview": "from __future__ import annotations\n\nimport re\nimport sys\nfrom types import TracebackType\n\nimport pytest\n\nimport trio\nfro"
  },
  {
    "path": "src/trio/_tests/test_threads.py",
    "chars": 40453,
    "preview": "from __future__ import annotations\n\nimport contextvars\nimport queue as stdlib_queue\nimport re\nimport sys\nimport threadin"
  },
  {
    "path": "src/trio/_tests/test_timeouts.py",
    "chars": 8643,
    "preview": "from __future__ import annotations\n\nimport time\nfrom typing import TYPE_CHECKING, Protocol, TypeVar\n\nimport outcome\nimpo"
  },
  {
    "path": "src/trio/_tests/test_tracing.py",
    "chars": 2410,
    "preview": "from __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nimport trio\n\nif TYPE_CHECKING:\n    from collection"
  },
  {
    "path": "src/trio/_tests/test_trio.py",
    "chars": 205,
    "preview": "def test_trio_import() -> None:\r\n    import sys\r\n\r\n    for module in list(sys.modules.keys()):\r\n        if module.starts"
  },
  {
    "path": "src/trio/_tests/test_unix_pipes.py",
    "chars": 10194,
    "preview": "from __future__ import annotations\n\nimport errno\nimport os\nimport select\nimport sys\nfrom typing import TYPE_CHECKING\n\nim"
  },
  {
    "path": "src/trio/_tests/test_util.py",
    "chars": 12089,
    "preview": "from __future__ import annotations\n\nimport sys\nimport types\nfrom typing import TYPE_CHECKING, TypeVar\n\nif TYPE_CHECKING:"
  },
  {
    "path": "src/trio/_tests/test_wait_for_object.py",
    "chars": 8334,
    "preview": "import os\n\nimport pytest\n\non_windows = os.name == \"nt\"\n# Mark all the tests in this file as being windows-only\npytestmar"
  },
  {
    "path": "src/trio/_tests/test_windows_pipes.py",
    "chars": 3346,
    "preview": "from __future__ import annotations\n\nimport sys\nfrom typing import TYPE_CHECKING\n\nimport pytest\n\nfrom .. import _core\nfro"
  },
  {
    "path": "src/trio/_tests/tools/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "src/trio/_tests/tools/test_gen_exports.py",
    "chars": 4982,
    "preview": "import ast\nimport sys\nfrom pathlib import Path\n\nimport pytest\n\nfrom trio._tests.pytest_plugin import skip_if_optional_el"
  },
  {
    "path": "src/trio/_tests/tools/test_mypy_annotate.py",
    "chars": 4114,
    "preview": "from __future__ import annotations\n\nimport io\nimport sys\nfrom typing import TYPE_CHECKING\n\nimport pytest\n\nfrom trio._too"
  },
  {
    "path": "src/trio/_tests/tools/test_sync_requirements.py",
    "chars": 2232,
    "preview": "from __future__ import annotations\n\nfrom pathlib import Path\nfrom typing import TYPE_CHECKING\n\nfrom trio._tests.pytest_p"
  },
  {
    "path": "src/trio/_tests/type_tests/check_wraps.py",
    "chars": 284,
    "preview": "# https://github.com/python-trio/trio/issues/2775#issuecomment-1702267589\n# (except platform independent...)\nimport trio"
  },
  {
    "path": "src/trio/_tests/type_tests/open_memory_channel.py",
    "chars": 107,
    "preview": "# https://github.com/python-trio/trio/issues/2873\r\nimport trio\r\n\r\ns, r = trio.open_memory_channel[int](0)\r\n"
  },
  {
    "path": "src/trio/_tests/type_tests/path.py",
    "chars": 5832,
    "preview": "\"\"\"Path wrapping is quite complex, ensure all methods are understood as wrapped correctly.\"\"\"\n\nimport io\nimport os\nimpor"
  },
  {
    "path": "src/trio/_tests/type_tests/subprocesses.py",
    "chars": 892,
    "preview": "import sys\n\nimport trio\n\n\nasync def test() -> None:\n    # this could test more by using platform checks, but currently t"
  },
  {
    "path": "src/trio/_tests/type_tests/task_status.py",
    "chars": 947,
    "preview": "\"\"\"Check that started() can only be called for TaskStatus[None].\"\"\"\n\nfrom trio import TaskStatus\nfrom typing_extensions "
  },
  {
    "path": "src/trio/_threads.py",
    "chars": 24196,
    "preview": "from __future__ import annotations\n\nimport contextlib\nimport contextvars\nimport inspect\nimport queue as stdlib_queue\nimp"
  },
  {
    "path": "src/trio/_timeouts.py",
    "chars": 6222,
    "preview": "from __future__ import annotations\n\nimport math\nimport sys\nfrom contextlib import contextmanager\nfrom typing import TYPE"
  },
  {
    "path": "src/trio/_tools/__init__.py",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "src/trio/_tools/gen_exports.py",
    "chars": 11602,
    "preview": "#! /usr/bin/env python3\n\"\"\"\nCode generation script for class methods\nto be exported as public API\n\"\"\"\n\nfrom __future__ i"
  },
  {
    "path": "src/trio/_tools/mypy_annotate.py",
    "chars": 3998,
    "preview": "\"\"\"Translates Mypy's output into GitHub's error/warning annotation syntax.\n\nSee: https://docs.github.com/en/actions/usin"
  },
  {
    "path": "src/trio/_tools/sync_requirements.py",
    "chars": 3175,
    "preview": "#!/usr/bin/env python3\n\n\"\"\"Sync Requirements - Automatically upgrade test requirements pinned\nversions from pre-commit c"
  },
  {
    "path": "src/trio/_tools/windows_ffi_build.py",
    "chars": 5561,
    "preview": "# builder for CFFI out-of-line mode, for reduced import time.\n# run this to generate `trio._core._generated_windows_ffi`"
  },
  {
    "path": "src/trio/_unix_pipes.py",
    "chars": 8234,
    "preview": "from __future__ import annotations\n\nimport errno\nimport os\nimport sys\nfrom typing import TYPE_CHECKING, Final as FinalTy"
  },
  {
    "path": "src/trio/_util.py",
    "chars": 13690,
    "preview": "# Little utilities we use internally\nfrom __future__ import annotations\n\nimport collections.abc\nimport inspect\nimport si"
  },
  {
    "path": "src/trio/_version.py",
    "chars": 94,
    "preview": "# This file is imported from __init__.py and parsed by setuptools\n\n__version__ = \"0.33.0+dev\"\n"
  },
  {
    "path": "src/trio/_wait_for_object.py",
    "chars": 2081,
    "preview": "from __future__ import annotations\n\nimport math\n\nimport trio\n\nfrom ._core._windows_cffi import (\n    CData,\n    ErrorCod"
  },
  {
    "path": "src/trio/_windows_pipes.py",
    "chars": 4855,
    "preview": "from __future__ import annotations\n\nimport sys\nfrom typing import TYPE_CHECKING\n\nfrom . import _core\nfrom ._abc import R"
  },
  {
    "path": "src/trio/abc.py",
    "chars": 907,
    "preview": "# This is a public namespace, so we don't want to expose any non-underscored\n# attributes that aren't actually part of o"
  },
  {
    "path": "src/trio/from_thread.py",
    "chars": 442,
    "preview": "\"\"\"\nThis namespace represents special functions that can call back into Trio from\nan external thread by means of a Trio "
  },
  {
    "path": "src/trio/lowlevel.py",
    "chars": 3583,
    "preview": "\"\"\"\nThis namespace represents low-level functionality not intended for daily use,\nbut useful for extending Trio's functi"
  },
  {
    "path": "src/trio/py.typed",
    "chars": 0,
    "preview": ""
  }
]

// ... and 19 more files (download for full content)

About this extraction

This page contains the full source code of the python-trio/trio GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 219 files (2.2 MB), approximately 579.4k tokens, and a symbol index with 2206 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!