Message124983
| Author |
terry.reedy |
| Recipients |
docs@python, nailor, terry.reedy |
| Date |
2011年01月01日.00:37:39 |
| SpamBayes Score |
8.254508e-13 |
| Marked as misclassified |
No |
| Message-id |
<1293842261.45.0.624055406573.issue10789@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| 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 |
|