Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concurrent.futures.ThreadPoolExecutor does not use a default value #65726

Closed
PCManticore mannequin opened this issue May 18, 2014 · 5 comments
Closed

concurrent.futures.ThreadPoolExecutor does not use a default value #65726

PCManticore mannequin opened this issue May 18, 2014 · 5 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@PCManticore
Copy link
Mannequin

PCManticore mannequin commented May 18, 2014

BPO 21527
Nosy @gvanrossum, @brianquinlan, @PCManticore, @MojoVampire
Files
  • concurrent_futures_workers.patch
  • issue21527.patch: Update max_workers
  • 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-09-02.17:39:27.734>
    created_at = <Date 2014-05-18.22:47:47.410>
    labels = ['type-feature', 'library']
    title = 'concurrent.futures.ThreadPoolExecutor does not use a default value'
    updated_at = <Date 2014-09-02.17:39:27.732>
    user = 'https://github.com/PCManticore'

    bugs.python.org fields:

    activity = <Date 2014-09-02.17:39:27.732>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-09-02.17:39:27.734>
    closer = 'python-dev'
    components = ['Library (Lib)']
    creation = <Date 2014-05-18.22:47:47.410>
    creator = 'Claudiu.Popa'
    dependencies = []
    files = ['35287', '36494']
    hgrepos = []
    issue_num = 21527
    keywords = ['patch']
    message_count = 5.0
    messages = ['218763', '218840', '226032', '226212', '226278']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'bquinlan', 'Claudiu.Popa', 'python-dev', 'josh.r']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue21527'
    versions = ['Python 3.5']

    @PCManticore
    Copy link
    Mannequin Author

    PCManticore mannequin commented May 18, 2014

    As the title says, ThreadPoolExecutor does not use a default value for max_workers parameter, as ProcessPoolExecutor does. When the user does not care about the number of workers and wants only for something to run in background, he has to write code like this:

    if processes:
       executor = ProcessPoolExecutor()
    elif threads:
       executor = ThreadPoolExecutor(1) # or any other value

    This situation can also occur when the class is passed as a factory function:

    def create_pool(executor_factory):
       if executor_factory is process pool:
           executor = executor_factory()
       else:
           executor = executor_factory(1)

    This patch proposes using the number of cores as the default value for max_workers.
    For instance, multiprocessing.pool.ThreadPool uses the same value.

    @PCManticore PCManticore mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels May 18, 2014
    @MojoVampire
    Copy link
    Mannequin

    MojoVampire mannequin commented May 20, 2014

    +1. Makes it easier to swap Executors (which is a big selling point for the Executor framework), and number of cores is a reasonable default value.

    @gvanrossum
    Copy link
    Member

    Looks good.

    @PCManticore
    Copy link
    Mannequin Author

    PCManticore mannequin commented Sep 1, 2014

    Thank you, Guido.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Sep 2, 2014

    New changeset 2805b0dca798 by Guido van Rossum in branch 'default':
    Closes bpo-21527: Add default number of workers to ThreadPoolExecutor. (Claudiu Popa.)
    http://hg.python.org/cpython/rev/2805b0dca798

    @python-dev python-dev mannequin closed this as completed Sep 2, 2014
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant