threading and iterator crashing interpreter

Gabriel Genellina gagsl-py2 at
Sun Mar 11 18:42:13 CET 2007

En Sun, 11 Mar 2007 11:35:58 -0300, Janto Dreijer <jantod at>  

>> At least, the problem of using the same generator from different threads
>> still remains, if you don't use my modified code. In general, when using
>> multiple threads you always need some way to syncronize access to shared
>> objects. You are lucky with Sessions because append is an atomic  
>> operation
>> on lists; for more information see   
> Again you're right. But even putting a try-except:return around the
> random.choice still manages to break the interpreter. I'm not looking
> for any meaningful output really. I just want it not to break.

A try/except won't help a concurrency problem, unfortunately.

> Like I said, this is just watered down code to try and isolate the
> problem.

So I suggest to start with some small, *correct*, code, and then add more  
features until you reconstruct your big program in a safe way.

Gabriel Genellina

More information about the Python-list mailing list