[issue17389] Optimize Event.wait()

Richard Oudkerk report at bugs.python.org
Fri Mar 22 16:26:11 CET 2013


Richard Oudkerk added the comment:

On 22/03/2013 3:19pm, Charles-François Natali wrote:
> The _flag is checked without any lock held: although it won't be a
> problem with CPython, a standard memory model (e.g. Java's one)
> doesn't guarantee that reading _flag outside of the lock will return
> the value most recently written to it (because of caching/hoisting, or
> store buffers/invalidate queues at CPU level).
>
> So in short, if wait() is called by a thread shortly after another
> thread clear()ed it, the former thread might very well read _flag ==
> True (while the later just set it to False) and return erroneously.

I was under the impression that dict access (and therefore attribute 
access for "simple" objects) was guaranteed to be atomic even in 
alternative implementations like Jython and IronPython.

Is this not a language guarantee?

----------

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


More information about the Python-bugs-list mailing list