Bernard Lebel wrote: > On 1/19/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > >>Hi Bernard, >> >>I'm glad you got it working but kind of surprised at what you had to do. >>You shouldn't have to have a single thread to access the database. In >>your original desing were you sharing a connection between threads? That >>could cause trouble. But if each connection has its own thread and you >>are using transactions and isolation levels appropriately, they >>shouldn't stomp on each other. > > > I'm not sure what you mean by transaction and isolation levels. I get > some sort of an idea, but could you elaborate on the idea?
Transactions are helpful in two ways. One is to make a sequence of operations atomic - they either all succeed or all fail. A classic example is a banking transaction where you have to debit one account and credit another. You wouldn't want one request to succeed and the other fail - that would be disastrous. By wrapping the two operations in a transaction, the database ensures that they succeed or fail together. The other thing is to isolate the intermediate steps from other database clients. You might not want a second client to see the database in the intermediate step. By setting the proper isolation level on the transaction the database will not make the changes visible to other clients until the transaction commits. http://en.wikipedia.org/wiki/Database_transaction http://en.wikipedia.org/wiki/ACID > > I have not considered having one connection per thread, and have not > tested the idea. The way it works right now is that there is only one > connection, as a class instance attribute. All transaction go through > that connection. So you *were* sharing one connection between several threads before? ouch. I'm not surprised that that broke badly... Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor