List iterator thread safety

Aahz aahz at pythoncraft.com
Thu Aug 27 03:01:35 CEST 2009


In article <b7796993-219d-4f18-aea3-9af95468ccbc at z31g2000yqd.googlegroups.com>,
Emanuele D'Arrigo <manu3d at gmail.com> wrote:
>
>Let's say I have a list accessed by two threads, one removing list
>items via "del myList[index]" statement the other iterating through
>the list and printing out the items via "for item in myList:"
>statement. Am I right to say this -won't- generate exceptions because
>the list iterator is not concerned with the list changing in size
>under its nose? Or are there pitfalls I should be aware of?

Well, I'm not sure about exceptions, but you almost certainly won't get
the results you want.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"I support family values -- Addams family values" --www.nancybuttons.com



More information about the Python-list mailing list