This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients docs@python, tim.peters
Date 2013-09-04.21:54:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1378331648.69.0.879815072803.issue18927@psf.upfronthosting.co.za>
In-reply-to
Content
Here from the 3.3.2 docs for threading.Lock:

"""
acquire(blocking=True, timeout=-1) 
Acquire a lock, blocking or non-blocking.

...

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. 

...

"""

However, that's not what the code does for a negative timeout:

>>> from threading import Lock
>>> x = Lock()
>>> x.acquire(1, -0.2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: timeout value must be strictly positive

The only negative value the code allows is -1, in lock_PyThread_acquire_lock():

    if (timeout < 0 && timeout != -1) {
        PyErr_SetString(PyExc_ValueError, "timeout value must be "
                        "strictly positive");
        return NULL;
    }

The docs should change to say that -1 is special ;-)
History
Date User Action Args
2013-09-04 21:54:08tim.peterssetrecipients: + tim.peters, docs@python
2013-09-04 21:54:08tim.peterssetmessageid: <1378331648.69.0.879815072803.issue18927@psf.upfronthosting.co.za>
2013-09-04 21:54:08tim.peterslinkissue18927 messages
2013-09-04 21:54:08tim.peterscreate