Oleg Broytmann wrote: > On Mon, Feb 11, 2008 at 09:21:56PM -0500, Nathan Edwards wrote: >> If I change "a = A.byValue(1)" to "pass" the exceptions go away...it >> seems like the exception puts the connection in a bad state. > > 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. How do I issue a rollback on a connection - is there an implicit transaction here? Why is there a difference between 1 thread and many threads? Is this what you are suggesting? def thr1(): for i in range(1000): tr = A._connection.transaction() try: A(value=1) tr.commit(close=True) except dberrors.DuplicateEntryError: tr.rollback() a = A.byValue(1) Does not get rid of the "Commands out of sync..." exception. I also tried: def thr1(): sqlhub.threadConnection = connectionForURI(connuri) for i in range(1000): tr = sqlhub.threadConnection.transaction() try: a = AAA(value=1) tr.commit() except dberrors.DuplicateEntryError: tr.rollback() a = AAA.byValue(1) Still no luck. Is there a better idiom for: Create a new object unless it already exists (as defined by UNIQUE indexes), if so get it. I can't just check with a select because some other process or thread may create the object before I can, hence the DuplicateEntryError. - n -- Dr. Nathan Edwards [EMAIL PROTECTED] Department of Biochemistry and Molecular & Cellular Biology Georgetown University Medical Center Room 1215, Harris Building Room 347, Basic Science 3300 Whitehaven St, NW 3900 Reservoir Road, NW Washington DC 20007 Washington DC 20007 Phone: 202-687-7042 Phone: 202-687-1618 Fax: 202-687-0057 Fax: 202-687-7186 ------------------------------------------------------------------------- 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 sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss