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

multiprocessing.Pool.imap swallows exceptions thrown by generators #72811

Closed
elias6 mannequin opened this issue Nov 6, 2016 · 4 comments
Closed

multiprocessing.Pool.imap swallows exceptions thrown by generators #72811

elias6 mannequin opened this issue Nov 6, 2016 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@elias6
Copy link
Mannequin

elias6 mannequin commented Nov 6, 2016

BPO 28625
Nosy @elias6, @applio
Superseder
  • bpo-28699: Imap from ThreadPool behaves unexpectedly
  • 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 2016-11-25.22:07:05.519>
    created_at = <Date 2016-11-06.16:16:43.548>
    labels = ['type-bug', 'library']
    title = 'multiprocessing.Pool.imap swallows exceptions thrown by generators'
    updated_at = <Date 2016-11-25.22:07:05.518>
    user = 'https://github.com/elias6'

    bugs.python.org fields:

    activity = <Date 2016-11-25.22:07:05.518>
    actor = 'davin'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-11-25.22:07:05.519>
    closer = 'davin'
    components = ['Library (Lib)']
    creation = <Date 2016-11-06.16:16:43.548>
    creator = 'elias'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 28625
    keywords = []
    message_count = 4.0
    messages = ['280146', '280913', '280957', '281744']
    nosy_count = 2.0
    nosy_names = ['elias', 'davin']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '28699'
    type = 'behavior'
    url = 'https://bugs.python.org/issue28625'
    versions = ['Python 3.5', 'Python 3.6']

    @elias6
    Copy link
    Mannequin Author

    elias6 mannequin commented Nov 6, 2016

    I have the following code:

    from multiprocessing import Pool
    
    def double(x):
        return 2 * x
    
    def get_numbers():
        raise Exception("oops")
        yield 1
        yield 2

    print(list(Pool(processes=2).imap(double, get_numbers())))

    I would expect it to raise an exception, but instead it just prints "[]", seeming to indicate that imap ran fine and produced no values.

    This seems similar to the behavior described in bugs 23051 and 26333, but this happens if the iterator directly raises an exception before yielding anything. If I move the raise statement below one or both of the yields, I get an exception from imap as expected.

    I am experiencing this with Python 3.5.2 on OS X 10.11.6. I haven't tried it with any other versions.

    @elias6 elias6 mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Nov 6, 2016
    @elias6
    Copy link
    Mannequin Author

    elias6 mannequin commented Nov 16, 2016

    I tried my code in Python 3.6.0b3 and got the same result.

    @applio
    Copy link
    Member

    applio commented Nov 16, 2016

    In bpo-28699, an important clue has been identified (a variation on the generator triggers a different, inconsistent behavior). I will merge this issue into that one to keep us all on the same page.

    @applio
    Copy link
    Member

    applio commented Nov 25, 2016

    Closing this issue -- all further discussion moves to bpo-28699

    @applio applio closed this as completed Nov 25, 2016
    @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