FYI...I found this interesting.

>Date: Sun, 17 Jun 2001 17:46:54 -0400 (EDT)
>From: Andy Dustman <[EMAIL PROTECTED]>
>Sender: <[EMAIL PROTECTED]>
>To: Chuck Esterbrook <[EMAIL PROTECTED]>
>Subject: Re: MySQLdb module: threadsafety went down?
>Copyright: 2001 by Andy Dustman
>
>On Sun, 17 Jun 2001, Chuck Esterbrook wrote:
>
> > threadsafety used to be 2, but is now 1, meaning threads can no longer
> > share a connection.
> >
> > What was the reason for the decrement? Were the previous versions buggy
> > with 2? Or did the new version change such that 2 was no longer feasible?
>
>There was too much locking code required to do it correctly, and I think
>sharing connections is a bad idea in the first place. If you know what
>you're doing, you can wrap connections with a mutex. This is effectively
>what happens, for example, in Zope.
>
>I actually enhanced the locking mechanism somewhat in the not-released
>0.3.6. That's what convinced me it should be taken out. The two things
>which together make it nearly intractable are:
>
>a) mysql_store_result() vs. mysql_use_result(). With the former, all rows
>are transferred to the client all at once, and sharing the connection is
>easy. With the latter, rows are transferred with each mysql_fetch_row()
>call, and you must fetch all the rows prior to starting another query.
>Thus the connection lock has to be held until the last row is read. This
>lock was managed by their respective cursor mixins.
>
>b) Transactions: If they are enabled, you cannot safely share the
>connection from the time a transaction begins until the time it is
>committed or rolled back. (I doubt most situations would call for multiple
>threads engaging in the same transaction.) This requires an additional
>lock, acquired by the cursor but released by the connection object, which
>implements commit/rollback.
>
>Combine both of those, and it's a big mess. Better off not to share
>connections in the first place. It makes the code much simpler.
>
>--
>Andy Dustman         PGP: 0xC72F3F1D
>     @       .net     http://dustman.net/andy
>"I'd rather listen to Newton than to Mundie. He may have been dead for almost
>three hundred years, but despite that he stinks up the room less." -- 
>Linus T.


_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to