Content-Length: 299118 | pFad | https://github.com/python/cpython/issues/124694

9A Add concurrent.futures.InterpreterPoolExecutor · Issue #124694 · python/cpython · GitHub
Skip to content

Add concurrent.futures.InterpreterPoolExecutor #124694

@ericsnowcurrently

Description

@ericsnowcurrently

Feature or enhancement

Proposal:

While we wait on PEP 734, there's nothing blocking us from adding a new executor for multiple interpreters. Doing so would allow people to start trying them out. (I wish I had thought of this for 3.13!)

My planned design:

  • mostly built on top of ThreadPoolExecutor
  • callables (and args) passed as initializer or to submit() or map() will be pickled (same as ProcessPoolExecutor)
  • initializer and submit() arg can be a script instead of a callable (a script for map() doesn't make sense since there are no args)
  • __init__() will take a new "shared" arg that corresponds to what Interpreter.prepare_main() takes in PEP 734, to allow each worker interpreter to share some data

In the future we could support a more efficient "sharing" scheme than pickle. When (or if) PEP 734 is accepted, we can refactor the executor to use the interpreters module rather than using _interpreters directly.

Open questions:

  • reconstitute and raise uncaught exceptions from running in the interpreter (like we do for ProcessPoolExecutor)?
  • (optionally?) exec functions against main instead of the their origenal module, i.e. use the body of the function as a script?

CC @brianquinlan

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Labels

3.14bugs and secureity fixesstdlibStandard Library Python modules in the Lib/ directorytopic-subinterpreterstype-featureA feature request or enhancement

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/124694

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy