On 12/12/06, Philip Jenvey <[EMAIL PROTECTED]> wrote:
> On Dec 12, 2006, at 2:32 PM, Mike Orr wrote:
> > Hi.  There's a discussion on the Pylons list about whether it's OK to
> > put a thread-unsafe database connection in pylons.g, which is a
> > paste.registry.StackedObjectProxy.  I want to put a Durus connection
> > there.  My reading of the paste.registry docstring says this is OK.
> > Could somebody confirm?  Thanks.
> >
>
> The Globals object is global to your entire application. Pylons
> creates one instance of it at startup and your application will see
> that same Globals object as pylons.g in every thread. Your single
> connection created in g would be shared among threads (not thread safe!)
>
> The thread safety in this case ensures a separate Pylons app deployed
> under the same container/process would see its own Globals object
> instead of your first apps' as pylons.g when concurrently serving a
> request in a separate thread.
>
> If you want to recycle the connections in between different requests
> you'll need a connection pool.

I bet it's possible to setup the connection in the base class and
store it in thread local storage.  Hence, you'll have a) a place to
put the code b) a way to make it one connection per thread.  I'm sure
it won't be hard to set this up, but I can't give you code from the
top of my head.

Best Regards,
-jj

-- 
http://jjinux.blogspot.com/

_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users

Reply via email to