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.1.tar.gz (8.0 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.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiointerpreters-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 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.1.tar.gz
Algorithm Hash digest
SHA256 b3b9ba1a308bd0b5edfe65bfb32c5ea630da0ed6e9f2dcb11ef9093aaff525c0
MD5 5288673ccf43667d5d4809c345c2f546
BLAKE2b-256 b5510443a2078ae760778a8f51734a284941e5ba1cdd0a0b31459c6faaa6918e

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiointerpreters-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aiointerpreters-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae6207bc5b6d9d8d281bd73e70473d59f3155ea80364a56eab0ec8d2d712fa48
MD5 a215edb02d909b866abbd4add3f4f255
BLAKE2b-256 f16e1e27b8bbe0b8fecf05fdea17e73e8169bc9e23cf2a105890650b345dbf5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiointerpreters-0.1.1-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