Skip to content

PyMutex re-entrancy not documented, confusing existing doc #146536

@rogerbinns

Description

@rogerbinns

Documentation

The doc for PyMutex is very unclear if the mutex is re-entrant. Can PyMutex_Lock be called multiple times in the same thread? Do there have to be an equal number of PyMutex_Unlock calls?

The PyMutex_Lock doc says it will succeed if the thread already has the lock. PyMutex_Unlock makes no mention of it having to be called in the same thread, or if any thread is okay.

Elsewhere it says the mutex is one byte, which is not enough to do any form of counting.

The relevance is that I have C code wrapping a library and that library can make callbacks. That means there are multiple paths through the call stack. A re-entrant counting mutex would work perfectly, and it is impossible to use a non-counted lock in that scenario, short of implementing another layer of locking to do the counting.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions