Skip to content

[subinterpreters] Make the PyGILState API compatible with multiple interpreters #55124

Closed

Description

@pitrou
BPO 10915
Nosy @loewis, @mhammond, @ronaldoussoren, @amauryfa, @ncoghlan, @pitrou, @vstinner, @phsilva, @encukou, @ericsnowcurrently, @soltysh
Dependencies
  • bpo-10914: Python sub-interpreter test
  • Superseder
  • bpo-15751: [subinterpreters] Make the PyGILState API compatible with subinterpreters
  • Files
  • gilstateinterp.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 = <Date 2020-05-15.01:26:55.685>
    created_at = <Date 2011-01-15.14:52:39.797>
    labels = ['expert-subinterpreters', 'type-feature', '3.8', '3.9']
    title = '[subinterpreters] Make the PyGILState API compatible with multiple interpreters'
    updated_at = <Date 2020-05-15.01:26:55.684>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2020-05-15.01:26:55.684>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-05-15.01:26:55.685>
    closer = 'vstinner'
    components = ['Subinterpreters']
    creation = <Date 2011-01-15.14:52:39.797>
    creator = 'pitrou'
    dependencies = ['10914']
    files = ['20417']
    hgrepos = []
    issue_num = 10915
    keywords = ['patch']
    message_count = 22.0
    messages = ['126333', '126335', '126348', '126349', '126351', '126354', '126355', '126357', '126363', '126364', '126366', '126387', '126400', '126402', '126406', '206041', '206047', '261778', '334266', '334451', '358263', '368903']
    nosy_count = 13.0
    nosy_names = ['loewis', 'mhammond', 'ronaldoussoren', 'amaury.forgeotdarc', 'ncoghlan', 'pitrou', 'vstinner', 'phsilva', 'grahamd', 'petr.viktorin', 'python-dev', 'eric.snow', 'maciej.szulik']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '15751'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue10915'
    versions = ['Python 3.8', 'Python 3.9']

    Activity

    1. pitrou commented on Jan 17, 2011

      @pitrou
      MemberAuthor

      Graham - the cases you describe are the things I was saying don't
      currently work in my post and wouldn't be helped by Antoine's patch.
      Your thoughts on how we could possibly make it work actually parallel
      mine (although there may be fun and games with making sure the
      respective GILs are acquired and released in an appropriate order when
      switching interpreters).

      There is only a single GIL, not one per interpreter. And this mustn't
      change since some objects are shared and their reference counts
      shouldn't be touched concurrently.

    2. ncoghlan commented on Jan 17, 2011

      @ncoghlan
      Contributor

      Good point - consider that comment revised to refer to the GIL acquisition counter in the thread state struct. It may just be a matter of having ThreadState_Swap complain loudly if the gilstate_counter isn't set to a value it knows how to handle.

    3. python-dev commented on Dec 13, 2013

      python-devmannequin
      Mannequin

      New changeset 5d078b0bae75 by Victor Stinner in branch 'default':
      Issue bpo-19787: PyThread_set_key_value() now always set the value
      http://hg.python.org/cpython/rev/5d078b0bae75

    4. vstinner commented on Dec 13, 2013

      @vstinner
      Member

      See also issue bpo-15751.

    5. python-dev commented on Mar 14, 2016

      python-devmannequin
      Mannequin

      New changeset e590c632c9fa by Victor Stinner in branch 'default':
      Add more checks on the GIL
      https://hg.python.org/cpython/rev/e590c632c9fa

    6. pitrou commented on Jan 23, 2019

      @pitrou
      MemberAuthor

      Patch probably doesn't apply anymore.

    7. ncoghlan commented on Jan 28, 2019

      @ncoghlan
      Contributor

      A more recent discussion of this on python-dev: https://mail.python.org/pipermail/python-dev/2019-January/156095.html

      The situation there appears to be a case of "Hand off an OS level thread from the creating interpreter to a different subinterpreter. As far as I can tell, calling GILState_Ensure in such a thread will still acquire the GIL of the creating interpreter (or something equally nonsensical)."

      It's a single-threaded application using subinterpreters, but all the callbacks from the NumPy code end up hitting the original interpreter that initialised the thread local state in the main thread.

    8. vstinner commented on Dec 11, 2019

      @vstinner
      Member

      See also bpo-1021318: "PyThreadState_Next not thread safe".

    9. added and removed
      interpreter-core
      on May 15, 2020
    10. changed the title [-]Make the PyGILState API compatible with multiple interpreters[/-] [+][subinterpreters] Make the PyGILState API compatible with multiple interpreters[/+] on May 15, 2020
    11. vstinner commented on May 15, 2020

      @vstinner
      Member

      I marked this issue as a duplicate of bpo-15751.

    12. transferred this issue fromon Apr 10, 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.8 (EOL)3.9 (EOL)topic-subinterpreterstype-feature

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions