On Tue, Feb 12, 2008 at 09:18:02AM -0500, Nathan Edwards wrote:
> Oleg Broytmann wrote:
> > My guess is that after any unhandled exception you must rollback the
> > connection.
>
> I'm not using transactions explicitly, each insert is atomic, so
> autoCommit is fine for me.
Then my guess is wrong. Sorry.
> How do I issue a rollback on a connection - is there an implicit
> transaction here?
No, transactions in SQLObject are always opened explicitly.
> Why is there a difference between 1 thread and many threads?
No idea. I have never used multithreading - exactly because of problems
with synchronization, race conditions and deadlocks.
> def thr1():
> for i in range(1000):
> tr = A._connection.transaction()
After opening a transaction you are supposed to use the transaction as
the connection. Instead of
> try:
> A(value=1)
> tr.commit(close=True)
> except dberrors.DuplicateEntryError:
> tr.rollback()
> a = A.byValue(1)
it should be
try:
A(value=1, connection=tr)
tr.commit(close=True)
except dberrors.DuplicateEntryError:
tr.rollback()
tr.begin()
a = A.byValue(1, connection=tr)
Don't forget to .begin() a transaction anew after .commit(close)/.rollback().
IWBN also to catch exceptions at .byValue():
try:
a = A.byValue(1, connection=tr)
except:
print "Exception"
> Is there a better idiom for: Create a new object unless it already
> exists (as defined by UNIQUE indexes), if so get it.
There is no.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss