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

Remove assertion-based checking in multiprocessing #49251

Closed
jnoller mannequin opened this issue Jan 19, 2009 · 17 comments
Closed

Remove assertion-based checking in multiprocessing #49251

jnoller mannequin opened this issue Jan 19, 2009 · 17 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@jnoller
Copy link
Mannequin

jnoller mannequin commented Jan 19, 2009

BPO 5001
Nosy @pitrou, @berkerpeksag, @drallensmith
PRs
  • bpo-5001, bpo-31169: Fix two uninformative asserts in multiprocessing/managers.py #3078
  • bpo-5001: More-informative multiprocessing error messages #3079
  • Files
  • issue5001.diff: Refactored asserts
  • issue5001_v2.diff: Second iteration
  • 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 2017-08-29.22:53:00.428>
    created_at = <Date 2009-01-19.16:32:42.002>
    labels = ['3.7', 'type-feature', 'library']
    title = 'Remove assertion-based checking in multiprocessing'
    updated_at = <Date 2017-08-29.22:53:00.426>
    user = 'https://bugs.python.org/jnoller'

    bugs.python.org fields:

    activity = <Date 2017-08-29.22:53:00.426>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-08-29.22:53:00.428>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2009-01-19.16:32:42.002>
    creator = 'jnoller'
    dependencies = []
    files = ['23298', '23302']
    hgrepos = []
    issue_num = 5001
    keywords = ['patch']
    message_count = 17.0
    messages = ['80192', '112140', '112149', '144780', '144781', '144795', '217299', '300195', '300196', '300201', '300397', '300473', '300512', '300541', '300584', '301002', '301003']
    nosy_count = 8.0
    nosy_names = ['pitrou', 'jnoller', 'jesstess', 'sbt', 'vladris', 'berker.peksag', 'Winterflower', 'drallensmith']
    pr_nums = ['3078', '3079']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue5001'
    versions = ['Python 3.7']

    @jnoller
    Copy link
    Mannequin Author

    jnoller mannequin commented Jan 19, 2009

    Right now, the multiprocessing code is littered with statements like:

        assert self.\_popen is None, 'cannot start a process twice'
        assert self.\_parent_pid == os.getpid(), \\
               'can only start a process object created by current 
    

    process'
    assert not _current_process._daemonic, \
    'daemonic processes are not allowed to have children'

    These will obviously be stripped out if running in optimized mode -
    however its not cool to rely on these anyway, the code should be
    refactored to proper checks, e.g.:

        if not hasattr(lock, 'acquire'):
            raise AttributeError("'%r' has no method 'acquire'" % lock)

    @jnoller jnoller mannequin self-assigned this Jan 19, 2009
    @jnoller jnoller mannequin added the stdlib Python modules in the Lib dir label Jan 19, 2009
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 31, 2010

    @jesse: could you provide a patch that addresses this issue?

    @jnoller
    Copy link
    Mannequin Author

    jnoller mannequin commented Jul 31, 2010

    @mark Yeah - I'm the current multiprocessing maintainer. If I fix it, I'll just commit it :) I filed this as a to do against myself.

    @vladris
    Copy link
    Mannequin

    vladris mannequin commented Oct 2, 2011

    I attached a patch which replaces all asserts with checks that raise exceptions. I used my judgement in determining exception types but I might have been off in some places. Also, this patch replaces ALL asserts. It is possible that some of the internal functions should be kept using asserts but I am not familiar enough with the module to say which. I figured I'd better do the whole thing than reviewers can say where lines should be reverted to asserts.

    @pitrou
    Copy link
    Member

    pitrou commented Oct 2, 2011

    Thank you. I've attached some comments, click on the "review" link to read them.

    @vladris
    Copy link
    Mannequin

    vladris mannequin commented Oct 2, 2011

    Thanks for the quick review! I attached second iteration addressing feedback + changed all occurrences of checks like "type(x) is y" to "isinstance(x, y)".

    I would appreciate a second look because this patch has many small changes and even though I ran full test suit which passed, I'm afraid I made a typo somewhere :)

    @jesstess
    Copy link
    Member

    Thanks for the patches, vladris!

    I've reviewed the latest version, and it addresses all of Antoine's review feedback. Ezio left some additional feedback (http://bugs.python.org/review/5001/#ps3407) which still needs to be addressed.

    @berkerpeksag berkerpeksag added the type-feature A feature request or enhancement label Jan 21, 2016
    @pitrou
    Copy link
    Member

    pitrou commented Aug 12, 2017

    @drallensmith, the patch you commented on is very old and probably doesn't apply anymore. It would be useful to make an updated patch (or rather PR, as we are using Github for development now: see https://devguide.python.org/pullrequest/).

    @drallensmith
    Copy link
    Mannequin

    drallensmith mannequin commented Aug 12, 2017

    Patches (for 2.7 and 3.5; the code is identical, only the line numbers changed) for the portion I commented on can be found in bpo-31169.

    @pitrou
    Copy link
    Member

    pitrou commented Aug 12, 2017

    New changeset 48d9823 by Antoine Pitrou (Allen W. Smith, Ph.D) in branch 'master':
    bpo-5001, bpo-31169: Fix two uninformative asserts in multiprocessing/managers.py (bpo-3078)
    48d9823

    @drallensmith
    Copy link
    Mannequin

    drallensmith mannequin commented Aug 17, 2017

    Pull request submitted (4 days ago) for managers.py, queue.py; just added pool.py changes to those.

    @drallensmith drallensmith mannequin added the 3.7 (EOL) end of life label Aug 17, 2017
    @drallensmith
    Copy link
    Mannequin

    drallensmith mannequin commented Aug 18, 2017

    No discussion yet on pull request (5 days); just submitted fixes for util.py.

    @pitrou
    Copy link
    Member

    pitrou commented Aug 18, 2017

    Please allow us a bit of time :-) We are all volunteers here.

    @drallensmith
    Copy link
    Mannequin

    drallensmith mannequin commented Aug 18, 2017

    Sorry! I was starting to wonder if the PR had been overlooked somehow...

    @drallensmith
    Copy link
    Mannequin

    drallensmith mannequin commented Aug 19, 2017

    I've updated the PR to include all of the non-Windows-specific asserts; I am not sufficiently familiar with Windows multiprocessing to feel confident writing informative error messages.

    @pitrou
    Copy link
    Member

    pitrou commented Aug 29, 2017

    New changeset bd73e72 by Antoine Pitrou (Allen W. Smith, Ph.D) in branch 'master':
    bpo-5001: More-informative multiprocessing error messages (bpo-3079)
    bd73e72

    @pitrou
    Copy link
    Member

    pitrou commented Aug 29, 2017

    I suppose this can be closed now.

    @pitrou pitrou closed this as completed Aug 29, 2017
    @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
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants