Skip to content

Remove PyEval_ReInitThreads() from the public C API #80909

Description

@vstinner
BPO 36728
Nosy @gpshead, @vstinner
PRs
  • bpo-36728: Remove PyEval_ReInitThreads() from C API #13241
  • bpo-36728: Remove PyEval_ReInitThreads documentation #13282
  • 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 2019-05-13.10:35:55.872>
    created_at = <Date 2019-04-25.23:22:09.307>
    labels = ['interpreter-core', '3.8']
    title = 'Remove PyEval_ReInitThreads() from the public C API'
    updated_at = <Date 2019-05-13.14:22:56.780>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-05-13.14:22:56.780>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-13.10:35:55.872>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2019-04-25.23:22:09.307>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36728
    keywords = ['patch']
    message_count = 6.0
    messages = ['340868', '342147', '342279', '342291', '342306', '342333']
    nosy_count = 2.0
    nosy_names = ['gregory.p.smith', 'vstinner']
    pr_nums = ['13241', '13282']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue36728'
    versions = ['Python 3.8']

    Activity

    1. vstinner commented on Apr 25, 2019

      @vstinner
      MemberAuthor

      PyEval_ReInitThreads() is used internally by PyOS_AfterFork_Child(). I don't see the point of calling it directly. If you care of threads after fork, just call PyOS_AfterFork_Child(), no?

      I propose to remove PyEval_ReInitThreads() from the public C API.

      Problem: it's documented as a public function in High-level API of the Python Initialization API:
      https://docs.python.org/dev/c-api/init.html#c.PyEval_ReInitThreads

      On the Internet, I found a single project calling directly this function, but it's only in a test used to the test Python threading API:
      https://github.com/DataDog/go-python3/blob/master/thread_test.go

      func TestThreadInitialization(t *testing.T) {
      Py_Initialize()
      PyEval_InitThreads()

      	assert.True(t, PyEval_ThreadsInitialized())
      
      	PyEval_ReInitThreads()
      }

      I don't think that the PyEval_ReInitThreads() call here makes any sense.

    2. vstinner commented on May 11, 2019

      @vstinner
      MemberAuthor

      The function was added 19 years ago:

      commit fee3a2d
      Author: Guido van Rossum <guido@python.org>
      Date: Sun Aug 27 17:34:07 2000 +0000

      Charles Waldman's patch to reinitialize the interpreter lock after a
      fork.  This solves the test_fork1 problem.  (ceval.c, signalmodule.c,
      intrcheck.c)
      
      SourceForge: [ Patch bpo-101226 ] make threading fork-safe
      
    3. gpshead commented on May 13, 2019

      @gpshead
      Member

      fwiw - i agree that this can be removed. it has no reason to ever be called directly. i double checked in our massive internal codebase at work and found no calls other than python interpreters themselves.

    4. vstinner commented on May 13, 2019

      @vstinner
      MemberAuthor

      i double checked in our massive internal codebase at work and found no calls other than python interpreters themselves.

      Thanks. It confirms what I understood using GitHub code search (see my initial message).

    5. vstinner commented on May 13, 2019

      @vstinner
      MemberAuthor

      New changeset d5d9e81 by Victor Stinner in branch 'master':
      bpo-36728: Remove PyEval_ReInitThreads() from C API (GH-13241)
      d5d9e81

    6. vstinner commented on May 13, 2019

      @vstinner
      MemberAuthor

      New changeset c1f7262 by Victor Stinner in branch 'master':
      bpo-36728: Remove PyEval_ReInitThreads documentation (GH-13282)
      c1f7262

    7. 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)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions