[Python] Python 3.13 Threading lock.acquire vs lock.acquire_lock

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    In Python 3.13 (haven't checked lower versions) there seem to be two locking mechanisms for the threading.Lock class. I've looked online but found no mentions of acquire_lock or release_lock and wanted to ask if anyone knows what the difference is between them and the standard acquire and release methods.

    Here's the threading.Lock class for reference. The methods are commented as undocumented:

    class Lock:
    def __enter__(self) -> bool: ...
    def __exit__(
    self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
    ) -> None: ...
    def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
    def release(self) -> None: ...
    def locked(self) -> bool: ...
    def acquire_lock(self, blocking: bool = ..., timeout: float = ...) -> bool: ... # undocumented
    def release_lock(self) -> None: ... # undocumented
    def locked_lock(self) -> bool: ... # undocumented


    Just curious whether there's a difference between the call lock.acquire_lock and lock.acquire or whether this is merely a name-change that will take effect in the future.

    Continue reading...

Compartilhe esta Página