GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add -Xcpu_count=process cmdline mode to redirect os.cpu_count as os.process_cpu_count · Issue #110649 · python/cpython

Add -Xcpu_count=process cmdline mode to redirect os.cpu_count as os.process_cpu_count #110649

New issue
Copy link
New issue
Copy link
Closed
Closed
Add -Xcpu_count=process cmdline mode to redirect os.cpu_count as os.process_cpu_count#110649
Copy link
Labels
type-featureA feature request or enhancementA feature request or enhancement

Description

@corona10
corona10
opened on Oct 10, 2023
Issue body actions

Since we add the os. process_cpu_count from #109649 and -Xcpu_count= command from #109595, we can easily redirect os.cpu_count to os. process_cpu_count as we discussed at #109595 (comment)

Linked PRs

  • gh-110649: Update -Xcpu_count=<n> cmdline to support process mode #110639

Activity

  1. vstinner commented on Oct 10, 2023

    @vstinner
    vstinner
    on Oct 10, 2023
    Member
    More actions

    What's the use case of this option? Would you mind to elaborate?

    Why not modifying code to replace os.cpu_count() with os.process_cpu_count()?

    I have doubts that this function is really needed.

    cc @gpshead

  2. corona10 commented on Oct 10, 2023

    @corona10
    corona10
    on Oct 10, 2023
    MemberAuthor
    More actions

    Why not modifying code to replace os.cpu_count() with os.process_cpu_count()?

    Support -X cpu_count=process: os.cpu_count() becomes an alias to os.process_cpu_count(). So legacy applications using os.cpu_count() for use case (A) (decide how many worker processes should be run) and run in read-only containers with Python 3.13 can be run with -X cpu_count=process to use the correct number of CPUs. Obviously, -X cpu_count=number would remain available if the sysadmin has a good knowledge of its system or if Python returns the wrong number of CPUs (especially in groups).

    Well, I consider the case that if people want to replace it without modifying source code(3rd party library) from os.cpu_count() and os.process_cpu_count() by default.

  3. vstinner commented on Oct 10, 2023

    @vstinner
    vstinner
    on Oct 10, 2023
    Member
    More actions

    You can use export PYTHON_CPU_COUNT=$(python -c "import os; print(os.process_cpu_count())") which does the same, no?

    Reacted by Gregory P. Smith
  4. corona10 commented on Oct 11, 2023

    @corona10
    corona10
    on Oct 11, 2023
    MemberAuthor
    More actions

    Same! Then let's close it

    Reacted by Gregory P. Smith
  5. corona10
    closed this as completedon Oct 11, 2023
  6. corona10
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.