Geoffrey Talvola said:
> Christoph Zwerschke wrote:
>>  > import threading
>>  > t = threading.currentThread()
>>  > Then you can get and set arbitrary attributes on that
>>  > thread to achieve thread-local storage.  So a simple
>>  > implementation of a function that gets a thread-local
>>  > connection could look like this:
>>  > ...
>>
>> Thanks, that looks quite reasonable and simple. As discussed in
>> another posting, you could also add code that detects bad connections
>> and automatically restarts them; or connections that are too old or
>> have been reused too much.
>>
>> Do you think it would make sense to provide something like this as a
>> mix-in class for the WebKit Servlet or Page class?
>
> That's one approach.  On the other hand, there is nothing servlet-specific
> about the code I posted, so I think a standalone module would be better.
> It
> could then be used by scheduled tasks running in a worker thread, for
> example.
>

I agree that this should be implemented as a separate module.  I have
found uses for DbConnectionPool.py in a lot of code not running under
WebKit.  Since this is a similar concept, why make it WebKit specific?

One issue that has not been addressed is this:  What if I need more than
one connection per thread?  Why?  What if I am in the middle of a
multi-operation transaction that is updating the database using the first
connection and need to query the database from some disparate code?  It
would be nice if that disparate code could just obtain a connection, query
the database, and commit its transaction without having to know that the
other transaction existed.  The easiest way to accomplish this is with
separate connections.  This situation is handled automatically when using
DbConnectionPool since it uses the "check out/check in" concept.

Perhaps just adding "thread affinity" to DbConnectionPool would suffice. 
I think I have a TODO item to that affect.

-- 
Warren Smith
[EMAIL PROTECTED]


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel

Reply via email to