Re: Error during garbage collection after calling isready() on a closed connection

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <[email protected]>
Il giorno gio, 15/01/2009 alle 17.26 +0100, Brian Sutherland ha scritto:
> On Sat, Jan 10, 2009 at 07:08:24PM +0100, Federico Di Gregorio wrote:
> > Il giorno ven, 09/01/2009 alle 17.13 +0200, Brian Sutherland ha scritto:
> > > Hi,
> > > 
> > > Attached is an example script of a nasty little bug I found. It looks
> > > like calling .isready() on a server closed connection causes an error
> > > during the next garbage collection. That can cause all sorts of havoc on
> > > a python process.
> > > 
> > > I found it in version 2.5.1 and verified that it's still there in 2.0.8.
> > 
> > Hi,
> > 
> 
> I've backported your patch to 2.0.5.1 and it seems to work perfectly.
> Thanks!
> 
> > cursor.isready() now raise an exception if the internal call to libpq
> > reports problems. This is probably now _exactly_ what you want because
> > the first call to isready() after the disconnection results in a notice
> > (correctly appended to connections notices) and not in an error. An
> > error will be raised on any successive call that try to use the now
> > dropped connection.
> 
> Yes, raising an error on the isready() is _exactly_ what I want :)
[snip]
> In my application whether the exception is raised on the first or the
> second isready() calls isn't important. In fact, I can't think of a
> situation where it's important that the exception be raised exactly on
> the first isready() call after the connection is dropped.

Ah.. fine.

Have fun with psycopg,

federico

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           fog-NGVKUo/i/[email protected]
 In science one tries to tell people, in such a way as to be understood
  by everyone, something that no one ever knew before. But in poetry,
  it's the exact opposite.                                 -- Paul Dirac

_______________________________________________
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)

iEYEABECAAYFAklvfcQACgkQvcCgrgZGjeu2TACg1VJtixOH3xdU8+o+4iDOFk1p
jysAoLOCAA9dTvmluh4L3Hnj+LkkaM+g
=KelP
-----END PGP SIGNATURE-----
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.