Re: database connection pooling from mod_python app

Discussion in 'Python' started by Ian Bicking, Oct 8, 2003.

  1. Ian Bicking

    Ian Bicking Guest

    On Wednesday, October 8, 2003, at 11:23 AM, Anthony_Barker wrote:
    > I have been searching around for database connection pooling for a
    > mod_python app.


    My understanding is that you don't really need connection pooling in
    mod_python -- you can simply put the connection in a global variable.
    Maybe with something like:

    def get_connection():
    global _conn
    try:
    return _conn
    except NameError:
    _conn = (make your connection)
    return _conn


    I don't know mod_python enough to know if there's other magic
    incantations you need. You don't need "pooling", because each request
    is served in its own process -- you simply want to reuse the connection
    for future requests. If there's 10 processes, you'll need 10 separate
    connections, but those 10 processes will over time serve many requests
    so you can use those 10 connections over and over.

    So this isn't direct advise -- you'll need to experiment on your own --
    but I'd suggest you not overthink it. I think it's simpler than you
    think.


    --
    Ian Bicking | | http://blog.ianbicking.org
    Ian Bicking, Oct 8, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Justin M
    Replies:
    0
    Views:
    414
    Justin M
    Dec 8, 2003
  2. Anthony_Barker
    Replies:
    0
    Views:
    361
    Anthony_Barker
    Oct 8, 2003
  3. Matt Goodall
    Replies:
    0
    Views:
    1,189
    Matt Goodall
    Oct 8, 2003
  4. Nick Kew
    Replies:
    0
    Views:
    387
    Nick Kew
    Feb 23, 2004
  5. fniles
    Replies:
    3
    Views:
    373
    Paul Clement
    Apr 24, 2007
Loading...

Share This Page