List iterator thread safety

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

In article <b7796993-219d-4f18-aea3-9af95468ccbc at>,
Emanuele D'Arrigo <manu3d at> 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           <*>

"I support family values -- Addams family values"

More information about the Python-list mailing list