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

noreply@sourceforge.net noreply@sourceforge.net
Wed, 27 Mar 2002 18:02:38 -0800


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

Category: Python Library
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Fiona Lim (fionalim)
Assigned to: Nobody/Anonymous (nobody)
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
>>> 



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

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