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 — cpu_count() unreliable on Windows · Issue #67226 · python/cpython

cpu_count() unreliable on Windows #67226

New issue
Copy link
New issue
Copy link
Closed
Closed
cpu_count() unreliable on Windows#67226
Copy link
Labels
OS-windowsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

mark-summerfield
mannequin
opened on Dec 12, 2014
Issue body actions
BPO 23037
Nosy @vstinner, @tjguk, @mark-summerfield, @zware, @zooba

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2014-12-12.13:13:57.454>
created_at = <Date 2014-12-12.12:36:11.806>
labels = ['type-bug', 'library', 'OS-windows']
title = 'cpu_count() unreliable on Windows'
updated_at = <Date 2014-12-12.13:13:57.452>
user = 'https://github.com/mark-summerfield'

bugs.python.org fields:

activity = <Date 2014-12-12.13:13:57.452>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2014-12-12.13:13:57.454>
closer = 'vstinner'
components = ['Library (Lib)', 'Windows']
creation = <Date 2014-12-12.12:36:11.806>
creator = 'mark'
dependencies = []
files = []
hgrepos = []
issue_num = 23037
keywords = []
message_count = 2.0
messages = ['232540', '232544']
nosy_count = 5.0
nosy_names = ['vstinner', 'tim.golden', 'mark', 'zach.ware', 'steve.dower']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue23037'
versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

Activity

  1. mark-summerfield commented on Dec 12, 2014

    @mark-summerfield
    mark-summerfieldmannequin
    on Dec 12, 2014
    MannequinAuthor
    More actions

    In message
    http://bugs.python.org/issue17914#msg188626
    Victor Stenner says

    "On Windows, GetSystemInfo() is called instead of reading an environment variable. I suppose that this function is more reliable."

    From my reading, and based on feedback from one of my customers, I believe he is correct and that GetSystemInfo() ought to be used on Windows. (It is available in pywin32 win32api.)

  2. mark-summerfield
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    OS-windows
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Dec 12, 2014
  3. vstinner commented on Dec 12, 2014

    @vstinner
    vstinner
    on Dec 12, 2014
    Member
    More actions

    The code getting the number of processors on Windows is different between the multiprocessing (Python 3.3) and os (Python 3.5) modules.

    multiprocessing (old code):

        try:
            num = int(os.environ['NUMBER_OF_PROCESSORS'])
        except (ValueError, KeyError):
            num = 0
    

    os (new code):

    SYSTEM_INFO sysinfo;
    GetSystemInfo(&sysinfo);
    ncpu = sysinfo.dwNumberOfProcessors;
    

    os.cpu_count() is already implemented with GetSystemInfo() in Python 3.5, so this issue can be closed. Thanks for the reminder Mark, it was useful to double check.

    If you want to take a look at the source code:
    https://hg.python.org/cpython/file/35b7dde7fd53/Modules/posixmodule.c#l16064

  4. vstinner
    closed this as completedon Dec 12, 2014
  5. ezio-melotti
    transferred this issue fromon Apr 10, 2022
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

    OS-windowsstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    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.