Terry J. Reedy <[email protected]> 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: d...@python -> terry.reedy
nosy: +terry.reedy
resolution: -> fixed
stage: -> committed/rejected
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue10789>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com