Visitar URL original
[subinterpreters] Support basic asynchronous cross-interpreter operations. · Issue #84752 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20240901142641/https://github.com/python/cpython/issues/84752
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[subinterpreters] Support basic asynchronous cross-interpreter operations. #84752

Open
ericsnowcurrently opened this issue May 8, 2020 · 2 comments
Assignees
Labels
3.9 only security fixes topic-C-API topic-subinterpreters type-feature A feature request or enhancement

Comments

@ericsnowcurrently
Copy link
Member

BPO 40572
Nosy @vstinner, @ericsnowcurrently
PRs
  • bpo-40572: [_xxsubinterpreters] Add a way to request basic operations in another interpreter. #20012
  • 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 = 'https://github.com/ericsnowcurrently'
    closed_at = None
    created_at = <Date 2020-05-08.22:28:51.133>
    labels = ['expert-subinterpreters', 'expert-C-API', 'type-feature', '3.9']
    title = '[subinterpreters] Support basic asynchronous cross-interpreter operations.'
    updated_at = <Date 2020-05-15.00:43:16.244>
    user = 'https://github.com/ericsnowcurrently'

    bugs.python.org fields:

    activity = <Date 2020-05-15.00:43:16.244>
    actor = 'vstinner'
    assignee = 'eric.snow'
    closed = False
    closed_date = None
    closer = None
    components = ['C API', 'Subinterpreters']
    creation = <Date 2020-05-08.22:28:51.133>
    creator = 'eric.snow'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40572
    keywords = ['patch']
    message_count = 1.0
    messages = ['368476']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'eric.snow']
    pr_nums = ['20012']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue40572'
    versions = ['Python 3.9']

    @ericsnowcurrently
    Copy link
    Member Author

    (This is a continuation of the work from bpo-33608. That issue ended up with a lot of baggage and clutter (due to problems that have since been resolved), so we closed it. This issue is where we're picking it up fresh.)

    When two interpreters are cooperating, there are sometimes operations that one of them needs the other to perform. Thus far this is limited to mutation or release of data/objects owned by that "other" interpreter. We need safe, reliable public C-API to facilitate such operations.

    All the necessary machinery already exists ("pending calls"), exposed in the internal C-API: _Py_AddPendingCall(). (There is a public Py_AddPendingCall(), but it should be removed.) That API adds a function to a per-interpreter queue, from which it is executed later (asynchronously) by the ceval loop of the interpreter's main thread. The challenge is that the repercussions of such async operations within the eval loop are not fully explored. We have some confidence because this is the same machinery used to handle signals. However, it's better avoid as much complexity in those async operations as possible. That is why we don't just expose _Py_AddPendingCall() in the public C-API.

    Instead the plan is to add a small number of public C-API functions that are each specific to a focused use case, ideally with with little/no chance of errors or other side effects. Initially we will target Py_DECREF(), PyMem_Free(), and PyBuffer_Release(). If we need more then we can assess those needs later.

    @ericsnowcurrently ericsnowcurrently added the 3.9 only security fixes label May 8, 2020
    @ericsnowcurrently ericsnowcurrently self-assigned this May 8, 2020
    @ericsnowcurrently ericsnowcurrently added topic-C-API type-feature A feature request or enhancement 3.9 only security fixes labels May 8, 2020
    @ericsnowcurrently ericsnowcurrently self-assigned this May 8, 2020
    @ericsnowcurrently ericsnowcurrently added topic-C-API type-feature A feature request or enhancement labels May 8, 2020
    @vstinner vstinner changed the title Support basic asynchronous cross-interpreter operations. [subinterpreters] Support basic asynchronous cross-interpreter operations. May 15, 2020
    @vstinner vstinner changed the title Support basic asynchronous cross-interpreter operations. [subinterpreters] Support basic asynchronous cross-interpreter operations. May 15, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @Hels15
    Copy link
    Contributor

    Hels15 commented Nov 20, 2023

    Could anyone help me understand the current state of this feature/issue?
    Thank you!

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes topic-C-API topic-subinterpreters type-feature A feature request or enhancement
    Projects
    Status: Todo
    Development

    No branches or pull requests

    3 participants