Re: improving async support in psycopg

Federico Di Gregorio <fog-NGVKUo/i/[email protected]> Wed, 24 Mar 2010 21:27:42 +0100
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On 23/03/2010 01:38, Jan Urbański wrote:
> This is basically a trimmed down version of what Markus Demleitner wrote
> a couple of months ago - it's missing the query cancellation feature
> that I will try to implement after reading the libpq documentation some
> more.
> 
> I'll keep on working on exposing more async features of the C library
> and adding more unit tests (I've started another thread with the fix for
> the test suite for PG 9.0).

I'll start by this email. I don't agree on exposing more and more
features of libpq. While async is surely backend specific (especially if
done trhough libpq) I'd like to keep the API generic enough to be
implemented by other database adapters.

Some random toughts:

In theory you should be able to start a query and then manage the cursor
as any file descriptor, using select() or poll() with less possible
psycopg-specific code. I think the best would be to have an attribute on
the connection object to specify the _default_ for cursor.execute() [I
don't like the idea of completely async connections].

Also, having a way to tell from the connection if an async query is
running seems a good idea, so, probably .isready() should exist both at
the cursor and connection level.

If reactors and coroutines require additional methods then we should
provide *one* API that expose enough functionality for all of them (but
I don't use such stuff so someone else will be required to do this work).

Anyway, I applied your patch because it is the first step we need. I'll
add some more tests in the next few days.

federico

-- 
Federico Di Gregorio                                       fog-NGVKUo/i/[email protected]
       Se sai che hai un ***** di file così, lo manovri subito. -- vodka

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 262 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkuqdcQACgkQvcCgrgZGjevwcwCfSMIyrPofU5kAYptwaIB7soZ9
N30AoMq0M1W5murk+ce2PzLUV18P8dZb
=z0UC
-----END PGP SIGNATURE-----