[docs] [issue10789] Lock.acquire documentation is misleading
Terry J. Reedy
report at bugs.python.org
Sat Jan 1 01:37:41 CET 2011
Terry J. Reedy <tjreedy at udel.edu> added the comment:
Since threading is written in Python, one might expect Lock to be written in Python and its methods to accept keywords. However, threading.py (3.2) has
_acquire_lock = _thread.acquire_lock
Lock = _aquire_lock
so threading.Lock objects are C-coded _thread.lock objects and hence *might* not accept keyword args.
In 3.1:
lock.acquire([waitflag]) # same 2.7
Lock.acquire(blocking=True) # [blocking=1] in 2.7
Indeed the first is correct.
>>> from threading import Lock
>>> l=Lock()
>>> l.acquire(blocking=True)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
l.acquire(blocking=True)
TypeError: acquire() takes no keyword arguments
>>> l.acquire(True)
True
r87596, r87596
In 3.2:
lock.acquire(waitflag=1, timeout=-1)
Lock.acquire(blocking=True, timeout=-1)
The edit in 3.2 is actually correct
>>> from threading import Lock
>>> l=Lock()
>>> l.acquire(blocking=True)
True
>>> l.acquire(timeout=1)
False
_thread.lock.acquire now accepts keywords.
----------
assignee: docs at python -> terry.reedy
nosy: +terry.reedy
resolution: -> fixed
stage: -> committed/rejected
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10789>
_______________________________________
More information about the docs
mailing list