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

"Non-Python created threads" documentation doesn't mention PyEval_InitThreads() #63775

Closed
vstinner opened this issue Nov 13, 2013 · 8 comments
Closed
Labels
docs Documentation in the Doc dir

Comments

@vstinner
Copy link
Member

BPO 19576
Nosy @pitrou, @vstinner, @tiran, @tzickel
Files
  • PyGILState_Ensure.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 2013-12-13.00:48:00.078>
    created_at = <Date 2013-11-13.21:49:30.812>
    labels = ['docs']
    title = '"Non-Python created threads" documentation doesn\'t mention PyEval_InitThreads()'
    updated_at = <Date 2016-01-03.19:08:17.956>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2016-01-03.19:08:17.956>
    actor = 'tzickel'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2013-12-13.00:48:00.078>
    closer = 'python-dev'
    components = ['Documentation']
    creation = <Date 2013-11-13.21:49:30.812>
    creator = 'vstinner'
    dependencies = []
    files = ['32609']
    hgrepos = []
    issue_num = 19576
    keywords = ['patch']
    message_count = 8.0
    messages = ['202787', '202815', '202821', '205999', '206000', '206002', '217860', '257426']
    nosy_count = 7.0
    nosy_names = ['pitrou', 'vstinner', 'christian.heimes', 'docs@python', 'python-dev', 'lolynx', 'tzickel']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue19576'
    versions = ['Python 3.3', 'Python 3.4']

    @vstinner
    Copy link
    Member Author

    While working on a unit test for the issue bpo-14432, I hit a bug. My C thread got the GIL with PyGILState_Ensure(), but it was strange because the main Python thread also had the GIL...

    Then I saw that gil_created() returned false. The solution is to call PyEval_InitThreads() to create the GIL.

    I was reading "Non-Python created threads" documentation, but this section doesn't mention PyEval_InitThreads().

    I don't know if it's something new in Python 3.2 with the new GIL.

    @vstinner vstinner added the docs Documentation in the Doc dir label Nov 13, 2013
    @pitrou
    Copy link
    Member

    pitrou commented Nov 14, 2013

    Perhaps we can fix PyGILState to call PyEval_InitThreads automatically?

    @vstinner
    Copy link
    Member Author

    Perhaps we can fix PyGILState to call PyEval_InitThreads automatically?

    Yes, I had the same idea. Here is a patch to call PyEval_InitThreads() in PyGILState_Ensure() for new threads.

    @vstinner
    Copy link
    Member Author

    So Antoine, what do you think of the fix?

    @pitrou
    Copy link
    Member

    pitrou commented Dec 13, 2013

    Looks good to me.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 13, 2013

    New changeset dc4e805ec68a by Victor Stinner in branch 'default':
    Close bpo-19576: PyGILState_Ensure() now initializes threads. At startup, Python
    http://hg.python.org/cpython/rev/dc4e805ec68a

    @python-dev python-dev mannequin closed this as completed Dec 13, 2013
    @lolynx
    Copy link
    Mannequin

    lolynx mannequin commented May 4, 2014

    this patch made a new issue<20891>

    @tzickel
    Copy link
    Mannequin

    tzickel mannequin commented Jan 3, 2016

    I think that the document regarding PyGILState_Ensure and PyEval_InitThreads should be clarified better, written in issue bpo-26003

    @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
    docs Documentation in the Doc dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants