kivy / kivy/python-for-android

Allow multiple python interpreters per process

Open
#2,609 1 comment 0 reactions 0 assignees View on GitHub
feature-request
Dominant language
Python
Stars
8.9k
Forks
2k
Avg merge
12h 20m
Merged PRs (30d)
9

Description

### Checklist

- [x] the issue is indeed a bug and not a support request
- [x] issue doesn't already exist: https://github.com/kivy/python-for-android/issues
- [ ] I have a short, runnable example that reproduces the issue
- [x] I reproduced the problem with the latest development version (`p4a.branch = develop`)
- [x] I used the grave accent (aka backticks) to format code or logs when appropriated

### Versions

- Python: 3.9
- OS: Linux
- Kivy: N/A
- Cython: N/A
- OpenJDK: 11

### Description

Currently the native code [starting the python interpreter](https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/bootstraps/common/build/jni/application/src/start.c) only handles a single interpreter per process. This limits how applications handle services (and soon workers) as the python interpreter always has to be run in a separate process instead of a separate thread in the current process. This is managed in the `AndroidManifest.xml` file by declaring `android:process` in the service declarations.

Python does support this via [sub-interpreters](https://docs.python.org/3/c-api/init.html#sub-interpreter-support), but the setup is more complex. It would be nice to support that, though. Particularly for workers where they currently have to use more complex `RemoteListenableWorker` class.

Contributor guide

Open the contributing guide

Research direction

Start with pythonforandroid/bootstraps/common/build/jni/application/src/start.c and review how the AndroidManifest.xml declares service processes. Read Python's sub-interpreter support documentation and consider how this relates to workers and RemoteListenableWorker. Done means services or workers can use multiple Python interpreters within one process instead of requiring separate processes.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, python
Domain
mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.