Skip to content

Make Executor.map work with infinite/large inputs correctly #74028

Closed

Description

@MojoVampire
BPO 29842
Nosy @brianquinlan, @ezio-melotti, @pkch, @MojoVampire, @dlukes, @leezu
PRs
  • bpo-29842: Make Executor.map less eager so it handles large/unbounded… #707
  • bpo-29842: Make Executor.map less eager so it handles large/unbounded… #18566
  • 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 = None
    created_at = <Date 2017-03-18.01:32:56.383>
    labels = ['3.8', 'library']
    title = 'Make Executor.map work with infinite/large inputs correctly'
    updated_at = <Date 2021-05-05.00:42:51.731>
    user = 'https://github.com/MojoVampire'

    bugs.python.org fields:

    activity = <Date 2021-05-05.00:42:51.731>
    actor = 'leezu'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2017-03-18.01:32:56.383>
    creator = 'josh.r'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 29842
    keywords = ['patch']
    message_count = 8.0
    messages = ['289789', '289790', '293677', '293708', '322390', '322391', '341565', '385067']
    nosy_count = 7.0
    nosy_names = ['bquinlan', 'ezio.melotti', 'max', 'josh.r', 'dlukes', 'Klamann', 'leezu']
    pr_nums = ['707', '18566']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue29842'
    versions = ['Python 3.8']

    Linked PRs

    Activity

    1. VannTen commented on Aug 18, 2022

      @VannTen

      And eventually, yielding results in the order that tasks complete, like multiprocessing.Pool.imap_unordered, could be added on top of this, which would be really neat. (I know there's concurrent.futures.as_completed, but again, that one doesn't handle infinite iterables.)

      Chiming in as I recently used as_completed assuming it was consuming lazily. Reading it's code, it seems to me it could be adapted directly rather than on top of this (using islice and "re prefetching" the amount of yielded futures on each iteration). Does the author have an opinion ?

    2. Jason-Y-Z commented on Feb 18, 2024

      @Jason-Y-Z
      Contributor

      Hey all, I had a go at resolving this based on the previous attempt in #114975. Please take a look if of interest @vstinner @VannTen

    3. ebonnal commented on Oct 17, 2024

      @ebonnal
      SponsorContributor

      Hi,
      I also think a lot of codebases could leverage the elegance of a lazier Executor.map.

      Here is a follow-up PR that introduces an optional buffersize param and doesn't alter the default behavior: #125663.
      I would greatly appreciate it if you could take a look 🙏🏻.

      Note: It’s very similar to @MojoVampire's proposal (followed up by @graingert and @Jason-Y-Z).
      cc: @vstinner @VannTen

    4. added
      type-featureA feature request or enhancement
      and removed on Dec 3, 2024
    5. moved this to In Progress in Multiprocessing issueson Dec 3, 2024
    6. added a commit that references this issue on Mar 13, 2025
    7. added a commit that references this issue on Mar 13, 2025
    8. added a commit that references this issue on Mar 13, 2025
    9. added 2 commits that reference this issue on Mar 17, 2025
    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

      stdlibStandard Library Python modules in the Lib/ directorytopic-multiprocessingtype-featureA feature request or enhancement

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions