[Python-bugs-list] [ python-Bugs-536017 ] threading.Lock().acquire bug

noreply@sourceforge.net noreply@sourceforge.net
Thu, 28 Mar 2002 02:33:31 -0800


Bugs item #536017, was opened at 2002-03-28 03:02
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=536017&group_id=5470

Category: Documentation
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Fiona Lim (fionalim)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: threading.Lock().acquire bug

Initial Comment:
According to the online documentation for threading
Lock objects, setting blocking=0 will produce a
non-blocking call.
But trying it in the command line causes the execution
to hang.
>>> import threading
>>> lock = threading.Lock()
>>> lock.acquire(blocking=0)
>>> lock.acquire(blocking=0)
[blocks]

----------------------------------
internal documentation claims that the keyword is wait,
but using wait produces the same problem:

>>> import threading
>>> lock = threading.Lock()
>>> lock.acquire.__doc__
'acquire([wait]) -> None or
Boolean\n(PyThread_acquire_lock() is an obsolete
synonym)\n\nLock the lock.  Without argument, this
blocks if the lock is already\nlocked (even by the same
thread), waiting for another thread to release\nthe
lock, and return None when the lock is acquired.\nWith
a Boolean argument, this will only block if the
argument is true,\nand the return value reflects
whether the lock is acquired.\nThe blocking operation
is not interruptible.'
>>> lock.acquire(wait=0)
>>> lock.acquire(wait=0)
[blocks]

---------------------------------
Not using a keyword works fine:
>>> import threading
>>> lock = threading.Lock()
>>> lock.acquire(0)
1
>>> lock.acquire(0)
0
>>> 



----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2002-03-28 11:33

Message:
Logged In: YES 
user_id=21627

This is fixed in Python 2.2; it will raise an exception
"acquire() takes no keyword arguments". That should make it
immediately clear how to read the documentation.



----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-03-28 04:31

Message:
Logged In: YES 
user_id=31435

Changed to docs and assigned to Fred for comment.  Any idea 
how we can make this clearer?  The docs don't claim this 
accepts a keyword argument, and lots of C functions simply 
ignore any keyword arguments that may be given.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=536017&group_id=5470