Skip to main content

Run CPU bound code with subinterpreters using asyncio.

Project description

aiointerpreters

Run CPU bound code in subinterpreters using asyncio.

Installation

Pick the tool of your choosing

uv add aiointerpreters
uv pip install aiointerpreters
pip install aiointerpreters
poetry add aiointerpreters
pdm add aiointerpreters
pipenv install aiointerpreters

Motivation

The concurrent.interpreters api will be added in Python 3.14.

There are several high level mechanisms to access subinterpreters, such as Interpreter.call_in_thread and InterpreterPoolExecutor. But they both come with drawbacks:

  • call_in_thread: only works for top level functions with no arguments.
  • InterpreterPoolExecutor: uses pickles to pass data between interpreters similar to ProcessPoolExecutor.

There are no simple options to take advantage of the fast shared memeory.

Architecture

We must run the interpreters in threads to achieve parallelism. In order to notify futures in the background we must also have a coordniator thread to handle the results.

sequenceDiagram
  participant M as Main
  participant C as Coordinator
  participant W1 as Worker 1
  participant W2 as Worker 2
  M ->> W1: task queue
  M ->> W2: task queue
  W1 -->> C: result queue
  C -->> M: notify
  W2 -->> C: result queue
  C -->> M: set_result

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiointerpreters-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiointerpreters-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file aiointerpreters-0.1.0.tar.gz.

File metadata

  • Download URL: aiointerpreters-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aiointerpreters-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2fc36d069579a0e60d8a2ec012f4e6df108f182ebd46d5b97d05205aeaf6b37c
MD5 db47f9c1c8620433c8d6a82145fc186e
BLAKE2b-256 36865be6aff1b596b99cede5d16184191544f1d1732b31fc22a95b62aff18628

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiointerpreters-0.1.0.tar.gz:

Publisher: python-publish.yml on Jamie-Chang/aiointerpreters

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aiointerpreters-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiointerpreters-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56f5ddd3046a2d0e4ab72c09be4363a582736626d3df9b5b444207dd91f1316c
MD5 43b2b662b4b6906aeb1a12c8b24eeaef
BLAKE2b-256 29557a61b896764fad0feb98951fbc3635e4f36a547bf47360dd496974fd8b41

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiointerpreters-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on Jamie-Chang/aiointerpreters

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page