Question about threading.Lock().aquire(waitflag)

Tim Peters tim.peters at gmail.com
Tue Aug 30 19:41:50 EDT 2005


[ameyer2 at yahoo.com]
> is treated as a boolean or as a number.
> 
> Running on Windows, I get two different behaviors from
> the following calls to acquire:
>
>   aLock = threading.Lock()
>   ...
> 
>   # Thread 0
>   # This one often succeeds
>   aLock.acquire(1)
>   ...
> 
>   # Thread 1
>   # When this one would fail in a different thread
>   aLock.acquire(2)
> 
> but the behaviors aren't what I would expect if waitflag
> were a timeout value.

It's a Windows bug, fixed a while ago but not yet in a released
Python; here's the bug report:

    http://www.python.org/sf/1234979

2 _should_ have exactly the same effect as 1, but didn't on Windows.

> If the argument to acquire is a true/false flag, the
> behaviors for values of 1 and 2 ought to be the same.

Right, that's the intent.

> ...



More information about the Python-list mailing list