Re: Re: Organizing a Quixote/Durus multiprocess application

Damjan <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
> Oh look, another issue.  Where do I set my Durus ClientConnection in a
> SCGI app with multiple processes?  Do I have to open a ClientConnection 
> for every request (ugly)?

You need to open a connection for each process (or thread - since
ClientConnection is not thread safe).

I use this function in a database module (that also defines some model
classes):

def connect(address):
    tls = threading.local()
    try:
      connection = tls.connection
    except:
      connection = Connection(ClientStorage(address=address))
      tls.connection = connection
    return connection

This will also work with multiple processes.

-- 
damjan | дамјан
This is my jabber ID -->         [email protected] 
 -- not my mail address, it's a Jabber ID --^ :)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.