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 does not validate that max_workers is proper #65561

Closed
PCManticore mannequin opened this issue Apr 27, 2014 · 7 comments
Closed

concurrent.futures does not validate that max_workers is proper #65561

PCManticore mannequin opened this issue Apr 27, 2014 · 7 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@PCManticore
Copy link
Mannequin

PCManticore mannequin commented Apr 27, 2014

BPO 21362
Nosy @brianquinlan, @florentx, @PCManticore, @JimJJewett
Files
  • futures_max_workers.patch
  • issue21362.patch
  • issue21362_1.patch: Fix typo, don't duplicate the test.
  • 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 = 'https://github.com/brianquinlan'
    closed_at = <Date 2014-05-17.20:53:32.543>
    created_at = <Date 2014-04-27.11:39:29.212>
    labels = ['type-bug', 'library']
    title = 'concurrent.futures does not validate that max_workers is proper'
    updated_at = <Date 2014-05-17.20:53:32.541>
    user = 'https://github.com/PCManticore'

    bugs.python.org fields:

    activity = <Date 2014-05-17.20:53:32.541>
    actor = 'bquinlan'
    assignee = 'bquinlan'
    closed = True
    closed_date = <Date 2014-05-17.20:53:32.543>
    closer = 'bquinlan'
    components = ['Library (Lib)']
    creation = <Date 2014-04-27.11:39:29.212>
    creator = 'Claudiu.Popa'
    dependencies = []
    files = ['35053', '35057', '35058']
    hgrepos = []
    issue_num = 21362
    keywords = ['patch']
    message_count = 7.0
    messages = ['217258', '217259', '217280', '217376', '217532', '218714', '218715']
    nosy_count = 5.0
    nosy_names = ['bquinlan', 'flox', 'Claudiu.Popa', 'python-dev', 'Jim.Jewett']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'commit review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21362'
    versions = ['Python 3.4', 'Python 3.5']

    @PCManticore
    Copy link
    Mannequin Author

    PCManticore mannequin commented Apr 27, 2014

    Due to some bad math on my side, I passed max_workers=0 to concurrent.futures.ThreadPoolExecutor. This didn't fail properly, but hanged. The same behaviour occurs in ProcessPoolExecutor, but this time it fails internally with something like this:

    Exception in thread Thread-1:
    Traceback (most recent call last):
      File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner
        self.run()
      File "C:\Python34\lib\threading.py", line 869, in run
        self._target(*self._args, **self._kwargs)
      File "C:\Python34\lib\concurrent\futures\process.py", line 225, in _queue_management_worker
        assert sentinels
    AssertionError

    The attached patch checks that *max_workers* is <= 0 and raises ValueError if so.

    @PCManticore PCManticore mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Apr 27, 2014
    @PCManticore
    Copy link
    Mannequin Author

    PCManticore mannequin commented Apr 27, 2014

    For instance, multiprocessing behaves like this:

    >>> multiprocessing.Pool(-1)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Python34\lib\multiprocessing\context.py", line 118, in Pool
        context=self.get_context())
      File "C:\Python34\lib\multiprocessing\pool.py", line 157, in __init__
        raise ValueError("Number of processes must be at least 1")
    ValueError: Number of processes must be at least 1
    >>>

    @PCManticore
    Copy link
    Mannequin Author

    PCManticore mannequin commented Apr 27, 2014

    Attached patch with improvements suggested by Charles-François Natali. Thank you for the review.

    @jimjjewett
    Copy link
    Mannequin

    jimjjewett mannequin commented Apr 28, 2014

    I confirm the bug.
    The patch looks good.

    @brianquinlan
    Copy link
    Contributor

    The patch looks good to me too. I'll commit it soon.

    @brianquinlan brianquinlan self-assigned this Apr 29, 2014
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 17, 2014

    New changeset 3024ad49f00e by Brian Quinlan in branch 'default':
    Issue bpo-21362: concurrent.futures does not validate that max_workers is proper
    http://hg.python.org/cpython/rev/3024ad49f00e

    @brianquinlan
    Copy link
    Contributor

    Committed, thanks for the fix!

    @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-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant