En Sun, 11 Mar 2007 09:47:34 -0300, Janto Dreijer <[EMAIL PROTECTED]> escribió:
> As far as I can tell I'm not running it from restricted mode > explicitly. This error is rather strange then: > > RuntimeError: instance.__dict__ not accessible in restricted mode "restricted mode" means that the current builtins are not the standard builtins. > The reason I'm doing the random.choice() is so I don't have a handle > ("session" in this case) that would prevent it from being garbage > collected. I am not bothered by the Python-level Exceptions. I am > bothered by the interpreter throwing a segfault. What I suspect is > happening is the Session object is deallocated, while it still has a > reference from within the iterator. But on your code Session objects are never deleted; they stay inside System.sessions. Having an extra reference (the session variable) doesnt matter. > It's quite difficult to reproduce these bugs consistently. You might > need to run it a few times. 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 http://effbot.org/pyfaq/what-kinds-of-global-value-mutation-are-thread-safe.htm -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list