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] Multiple interpreters and readline module hook functions. #48452

Open
grahamd mannequin opened this issue Oct 25, 2008 · 5 comments
Open

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

grahamd mannequin opened this issue Oct 25, 2008 · 5 comments
Labels
topic-subinterpreters type-bug An unexpected behavior, bug, or error

Comments

@grahamd
Copy link
Mannequin

grahamd mannequin commented Oct 25, 2008

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']

    @grahamd
    Copy link
    Mannequin Author

    grahamd mannequin commented Oct 25, 2008

    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.

    @grahamd grahamd mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Oct 25, 2008
    @terryjreedy
    Copy link
    Member

    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.

    @Winston451
    Copy link
    Mannequin

    Winston451 mannequin commented Oct 25, 2012

    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.

    @Winston451
    Copy link
    Mannequin

    Winston451 mannequin commented Oct 26, 2012

    I attached a patch that solve the problem

    @Winston451 Winston451 mannequin added the type-bug An unexpected behavior, bug, or error label Oct 26, 2012
    @vstinner vstinner added topic-subinterpreters and removed interpreter-core (Objects, Python, Grammar, and Parser dirs) labels May 15, 2020
    @vstinner vstinner changed the title Multiple interpreters and readline module hook functions. [subinterpreters] Multiple interpreters and readline module hook functions. May 15, 2020
    @vstinner
    Copy link
    Member

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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-subinterpreters type-bug An unexpected behavior, bug, or error
    Projects
    Status: Todo
    Development

    No branches or pull requests

    2 participants