Re: psycopg2 vs psycopg1: the _v_database_connection problem in Zope 2
Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Organization | initd.org |
| Message-ID | <[email protected]> |
Il giorno mer, 24/09/2008 alle 09.39 +0200, Marco Bizzarri ha scritto: > On Tue, Sep 23, 2008 at 10:22 AM, Federico Di Gregorio <fog-NGVKUo/i/[email protected]> wrote: > Basically, my current choice on this topic is to create a patch to > ZPsycopgDA which (more or less): > > - instead of using an _v_ attribute uses a module level, thread > indexed dictionary, storying connections to the database > - each time needs a connection gets that from there > > As usual, I will have to use locks and try/finally to avoid > concurrent access to that, but that's all, more or less. > > Right? My suggestion is to switch to psycopg2 and modify the connection pool to keep used connections in a dictionary indexed by persistent keys (a serial number is fine). Then you store the connection in the _v_ attribute and the connection index in a persisten attribute. If at any time the _v_ attribute does not exists you check the serial number and recover the connection from the pool using it. This should work and solve all problems. federico -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer [email protected] INIT.D Developer fog-NGVKUo/i/[email protected] If nobody understand you, that doesn't mean you're an artist. -- anonymous _______________________________________________ Psycopg mailing list Psycopg-IAPFreCvJWPBWskQ1e/[email protected] http://lists.initd.org/mailman/listinfo/psycopg
signature.asc
(application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAkjZ77cACgkQvcCgrgZGjetc2gCfVEVezCHjzHPzmGef8d0RSlv0 BhgAoKGYjtE6kb1NRlmAnb/La1EymzCQ =UEoX -----END PGP SIGNATURE-----