[New-bugs-announce] [issue25516] threading.Condition._is_owned() is wrong when using threading.Lock

Nir Soffer report at bugs.python.org
Thu Oct 29 20:36:32 EDT 2015


New submission from Nir Soffer:

When using threading.Lock, threading.Condition._is_owned is assuming that the calling thread is owning the condition lock if the lock cannot be acquired. This check is completely wrong if another thread owns the lock.

>>> cond = threading.Condition(threading.Lock())
>>> threading.Thread(target=cond.acquire).start()
>>> cond._is_owned()
True
>>> cond.notify()
>>> cond.wait(0)
False

Careful users that acquire the condition before calling wait() or notify() are not effected. Careless users that should have been warned by RuntimeError are.

Tested on Python 2.7 and 3.4.2 and 3.6.0a0.

----------
components: Library (Lib)
messages: 253703
nosy: nirs
priority: normal
severity: normal
status: open
title: threading.Condition._is_owned() is wrong when using threading.Lock
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25516>
_______________________________________


More information about the New-bugs-announce mailing list