On Sat, Aug 9, 2014 at 10:32 AM, Chris Kaynor <ckay...@zindagigames.com> wrote: > The main issue I can see with that idea is that the exception will keep a > reference to the database connection (as with all locals), so unless you > explicitly close it within a finally clause, the database connection could > still be left hanging, and thus no rollback will occur.
To clarify: The simple example I used there was assumed to be the entire program, meaning that the process will terminate on exception. No worries about resource release then! This kind of model works nicely for anything that reads from one source and writes into the database, or processes data from the database back into the database, or anything like that. The general assumption is that an unexpected exception should be treated as fatal - just write to the console and terminate. While this might seem like the simplest 1% of cases, it's able to handle a lot of real-world situations. And since it takes no extra code, it's the perfect way to start :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list