Message124983
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. |
|
Date |
User |
Action |
Args |
2011-01-01 00:37:41 | terry.reedy | set | recipients:
+ terry.reedy, docs@python, nailor |
2011-01-01 00:37:41 | terry.reedy | set | messageid: <1293842261.45.0.624055406573.issue10789@psf.upfronthosting.co.za> |
2011-01-01 00:37:39 | terry.reedy | link | issue10789 messages |
2011-01-01 00:37:39 | terry.reedy | create | |
|