GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [subinterpreters] Fix pending calls in subinterpreters · Issue #84412 · python/cpython

[subinterpreters] Fix pending calls in subinterpreters #84412

New issue
Copy link
New issue
Copy link
Closed
Closed
[subinterpreters] Fix pending calls in subinterpreters#84412
Copy link
Labels
3.9 (EOL)end of lifeend of lifetopic-subinterpreters

Description

@vstinner
vstinner
opened on Apr 8, 2020
Issue body actions
BPO 40231
Nosy @vstinner, @ericsnowcurrently

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 = None
closed_at = None
created_at = <Date 2020-04-08.21:33:25.205>
labels = ['expert-subinterpreters', '3.9']
title = '[subinterpreters] Fix pending calls in subinterpreters'
updated_at = <Date 2020-05-15.00:39:53.889>
user = 'https://github.com/vstinner'

bugs.python.org fields:

activity = <Date 2020-05-15.00:39:53.889>
actor = 'vstinner'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Subinterpreters']
creation = <Date 2020-04-08.21:33:25.205>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 40231
keywords = []
message_count = 2.0
messages = ['366010', '366014']
nosy_count = 2.0
nosy_names = ['vstinner', 'eric.snow']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue40231'
versions = ['Python 3.9']

Activity

  1. vstinner commented on Apr 8, 2020

    @vstinner
    vstinner
    on Apr 8, 2020
    MemberAuthor
    More actions

    Currently, _Py_ThreadCanHandlePendingCalls() only returns true if the current thread is the Python "main thread" (_PyRuntime.main_thread).

    _PyRuntime.main_thread is initialized by _PyRuntime_Initialize().

    The problem is that a subinterpreter can run a separated thread which may not be the "main thread".

    As a consequence, a subinterpreter will not run schedulded pending calls, or it will run them later than it could.

    I modified COMPUTE_EVAL_BREAKER() of ceval.c in bpo-40010: now if tstate->interp->ceval.pending.calls_to_do is true, tstate->interp->ceval.eval_breaker is only set to 1 if _Py_ThreadCanHandlePendingCalls() is true.

    One option would be to allow any thread to run "pending calls".

    Another option is to have one "main thread" per interpreter, rather than having a single "main thread" for all interpreters.

    I made pending calls per-interpreter in bpo-39984.

    In Python 3.7, main_thread variable came from _PyRutimeState.ceval.pending.main_thread. It was moved into _PyRuntimeState by this change:

    commit 5be45a6
    Author: Eric Snow <[email protected]>
    Date: Fri Mar 8 22:47:07 2019 -0700

    bpo-33608: Minor cleanup related to pending calls. (gh-12247)
    

    --

    _Py_ThreadCanHandleSignals() doesn't have to change: it must only return true for the main thread of the main interpreter. Currently, it's implemented as:

    static inline int
    _Py_ThreadCanHandleSignals(PyThreadState *tstate)
    {
        return (_Py_IsMainThread() && _Py_IsMainInterpreter(tstate));
    }
  2. vstinner
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    3.9 (EOL)end of lifeend of life
    on Apr 8, 2020
  3. vstinner commented on Apr 8, 2020

    @vstinner
    vstinner
    on Apr 8, 2020
    MemberAuthor
    More actions

    I modified _PyEval_AddPendingCall() to accept interp rather than tstate to fix bpo-40082:

    New changeset b54a99d by Victor Stinner in branch 'master':
    bpo-40082: trip_signal() uses the main interpreter (GH-19441)
    b54a99d

  4. vstinner
    added
    topic-subinterpreters
    and removed
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on May 15, 2020
  5. vstinner
    changed the title [-]Fix pending calls in subinterpreters[/-] [+][subinterpreters] Fix pending calls in subinterpreters[/+] on May 15, 2020
  6. vstinner
    added
    topic-subinterpreters
    and removed
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on May 15, 2020
  7. vstinner
    changed the title [-]Fix pending calls in subinterpreters[/-] [+][subinterpreters] Fix pending calls in subinterpreters[/+] on May 15, 2020
  8. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  9. ezio-melotti
    added this to Subinterpreterson Apr 15, 2022
  10. ezio-melotti
    moved this to Todo in Subinterpreterson Apr 15, 2022
  11. vstinner commented on Nov 3, 2022

    @vstinner
    vstinner
    on Nov 3, 2022
    MemberAuthor
    More actions

    I don't have the bandwidth to work on this issue, so I just close it.

  12. vstinner
    closed this as completedon Nov 3, 2022
  13. Repository owner moved this from Todo to Done in Subinterpreterson Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.9 (EOL)end of lifeend of lifetopic-subinterpreters

    Projects

    • Subinterpreters
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.