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] Multiple interpreters and readline module hook functions. · Issue #48452 · python/cpython

[subinterpreters] Multiple interpreters and readline module hook functions. #48452

New issue
Copy link
New issue
Copy link
Closed
Closed
[subinterpreters] Multiple interpreters and readline module hook functions.#48452
Copy link
Labels
topic-subinterpreterstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

grahamd
mannequin
opened on Oct 25, 2008
Issue body actions
BPO 4202
Nosy @terryjreedy, @vstinner, @ericsnowcurrently
Files
  • readline.patch
  • 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 2008-10-25.02:52:43.004>
    labels = ['expert-subinterpreters', 'type-bug']
    title = '[subinterpreters] Multiple interpreters and readline module hook functions.'
    updated_at = <Date 2020-05-15.01:28:36.744>
    user = 'https://bugs.python.org/grahamd'

    bugs.python.org fields:

    activity = <Date 2020-05-15.01:28:36.744>
    actor = 'vstinner'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Subinterpreters']
    creation = <Date 2008-10-25.02:52:43.004>
    creator = 'grahamd'
    dependencies = []
    files = ['27727']
    hgrepos = []
    issue_num = 4202
    keywords = ['patch']
    message_count = 5.0
    messages = ['75201', '107981', '173809', '173839', '368905']
    nosy_count = 5.0
    nosy_names = ['terry.reedy', 'vstinner', 'grahamd', 'Winston451', 'eric.snow']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4202'
    versions = ['Python 3.5', 'Python 3.6']

    Activity

    1. grahamd commented on Oct 25, 2008

      @grahamd
      grahamdmannequin
      on Oct 25, 2008
      MannequinAuthor
      More actions

      Because the readline module uses PyGILState_Ensure() to facilitate triggering
      callbacks into Python code, this would make the ability to use the hook
      functions incompatible with use in sub interpreters.

      If this is the case, then that readline module cannot be used in sub
      interpreters should be documented if not already.

      Better still, attempts to register hooks from sub interpreters should result in
      an exception. Further, when in use, in sub interpreter, callback hooks should
      also not be called if defined, because if defined they would be the hooks from
      the main interpreter since variables holding the hooks are static C variables
      and shared across all interpreters.

      This issue derived from reading of code only and not tested in real program.

    2. grahamd
      added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
      on Oct 25, 2008
    3. terryjreedy commented on Jun 17, 2010

      @terryjreedy
      terryjreedy
      on Jun 17, 2010
      Member
      More actions

      The be an issue, tests with currents interpreters are needed. You may be right, but it may be that no one ever uses readline with subinterpreters.

    4. Winston451 commented on Oct 25, 2012

      @Winston451
      Winston451mannequin
      on Oct 25, 2012
      Mannequin
      More actions

      Hi,

      I'm currently developping an application which runs sub interpreters in threads (one sub interpreter per thread). When I try to use readline completion in these sub interpreters it fails because it's not possible to import the "keyword" module (PyEval_GetRestricted() returns true). I think it is due to the fact that readline's on_completion() use PyGILState_Ensure(). It should be possible to use PyEval_RestoreThread with _PyOS_ReadlineTState instead.

    5. Winston451 commented on Oct 26, 2012

      @Winston451
      Winston451mannequin
      on Oct 26, 2012
      Mannequin
      More actions

      I attached a patch that solve the problem

    6. Winston451
      added
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Oct 26, 2012
    7. vstinner
      added
      topic-subinterpreters
      and removed
      interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
      on May 15, 2020
    8. vstinner
      changed the title [-]Multiple interpreters and readline module hook functions.[/-] [+][subinterpreters] Multiple interpreters and readline module hook functions.[/+] on May 15, 2020
    9. vstinner commented on May 15, 2020

      @vstinner
      vstinner
      on May 15, 2020
      Member
      More actions

      See also bpo-15751: [subinterpreters] Make the PyGILState API compatible with subinterpreters.

    10. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    11. ezio-melotti
      added this to Subinterpreterson Apr 15, 2022
    12. ezio-melotti
      moved this to Todo in Subinterpreterson Apr 15, 2022
    13. ericsnowcurrently commented on Jul 8, 2024

      @ericsnowcurrently
      ericsnowcurrently
      on Jul 8, 2024
      Member
      More actions

      In the end, we kept the readline module single-phase init, which means it cannot be used in "isolated" subinterpreters (own GIL).
      Furthermore, @tonybaloney landed gh-112313 to resolve some of the complexity of the callbacks. I landed gh-121060 (3.13+) to force extensions to always be loaded in the main interpreter first, which resolves some of the other possible complexities. Overall, I believe this issue is sorted out.

      If we later want to work toward making the readline module work in multiple interpreters then I recommend we open a new issue.

      Reacted by Erlend E. Aasland
    14. ericsnowcurrently
      closed this as completedon Jul 8, 2024
    15. github-project-automation
      moved this from Todo to Done in Subinterpreterson Jul 8, 2024
    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

      topic-subinterpreterstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      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.