clifford.wells at comcast.net
Wed Oct 13 16:20:46 CEST 2004
On Wed, 2004-10-13 at 16:10 +0200, Diez B. Roggisch wrote:
> > Okay, to clarify, for the most part I *was* in fact referring to "higher
> > level issues". I doubt tracebacks or mangled data would occur simply
> > due to the operation's being non-atomic. However, if you have code that
> > say, checks for an item's existence in a list and then appends it if it
> > isn't there, it may cause the program to fail if another thread adds
> > that item between the time of the check and the time of the append.
> > This is what I was referring to by potential for mangled data and/or
> > tracebacks.
> _That_ of course I'm very well aware of - but to my expirience, with several
> dozen threads appending to one list I never encountered a interpreter
> failure. That is in contrast to java, where you get an
> "ConcurrentModificationException" unless you don't ask specifically for a
> synchronized variant of the collection of yours.
Have you looked at the Queue module? It was explicitly designed for
this sort of thing and removes all doubt about thread-safety.
Cliff Wells <clifford.wells at comcast.net>
More information about the Python-list