Index: Doc/library/threading.rst IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- Doc/library/threading.rst (revision 83698:ebc296bf23d1) +++ Doc/library/threading.rst (revision 83698+:ebc296bf23d1+) @@ -358,7 +358,7 @@ .. class:: Lock() The class implementing primitive lock objects. Once a thread has acquired a - lock, subsequent attempts to acquire it block, until it is released; any + lock, subsequent attempts to acquire it block until it is released; any thread may release it. .. versionchanged:: 3.3 @@ -367,23 +367,24 @@ .. method:: acquire(blocking=True, timeout=-1) - Acquire a lock, blocking or non-blocking. + Without any optional argument, this method acquires the lock + unconditionally, if necessary waiting until it is released by another + thread (only one thread at a time can acquire a lock). - When invoked with the *blocking* argument set to ``True`` (the default), - block until the lock is unlocked, then set it to locked and return ``True``. + If *blocking* is ``False``, the call returns immediately. If *blocking* + is ``True``, the lock is acquired unconditionally. In both cases + the return value indicates whether or not the lock was acquired. - When invoked with the *blocking* argument set to ``False``, do not block. - If a call with *blocking* set to ``True`` would block, return ``False`` - immediately; otherwise, set the lock to locked and return ``True``. + If the floating-point *timeout* argument is present and positive, it + specifies the maximum wait time in seconds before returning; the return + value indicates whether or not the lock was acquired. A negative + *timeout* argument specifies an unbounded wait and is the same as not + specifying a *timeout* and also setting *blocking* to ``True``. A zero + *timeout* is the same as not specifying a *timeout* and setting *blocking* + to ``False``. You cannot specify a *timeout* if *blocking* is ``False``. - When invoked with the floating-point *timeout* argument set to a positive - value, block for at most the number of seconds specified by *timeout* - and as long as the lock cannot be acquired. A negative *timeout* argument - specifies an unbounded wait. It is forbidden to specify a *timeout* - when *blocking* is false. - The return value is ``True`` if the lock is acquired successfully, - ``False`` if not (for example if the *timeout* expired). + ``False`` if not. .. versionchanged:: 3.2 The *timeout* parameter is new.