Re: improving async support in psycopg
Federico Di Gregorio <fog-NGVKUo/i/[email protected]> Mon, 29 Mar 2010 09:13:47 +0200
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On 28/03/2010 10:42, Jan UrbaĆski wrote: > On 28/03/10 04:10, Daniele Varrazzo wrote: >> On Sun, Mar 28, 2010 at 2:35 AM, Daniele Varrazzo >> <[email protected]> wrote: >> OTOH, looking at the pqpath.c, many functions call PQexec (via >> pq_execute_command_locked) and set the connection state according to >> its result (begin, commit and rollback). reset() instead executes a >> sequence of 2 or 3 operations (something similar to what connect() >> does). If those methods were to be made async, it seems to me that the >> knowledge about "how to block" should be available at C level. > > Yeah, there are places where psycopg2 issues queries behind your back :( > That's why I said that a user of the async features would probably have > to set the transaction isolation level to autocommit and issue his own > BEGINs and COMMITs from a Cursor.execute() instead. I still haven't skimmed over the patches but the more I read the paragraph above, the more I like it. It is reasonable that the client code using psycopg in async mode will usually be some asynchronous framework of some sort and not code written directly by the user. Then it make sense to depythonize the API a little bit and let the client code use psycopg as a facility to issue asynchronous queries. Also I don't think that keeping a single path in the code is such a good idea, so why not have a connect() call that when invoked with async=True takes a completely different path and setup everything for async mode? It will put the connection into autocommit and disable (meaning that they will raise an exception) methods such as commit(), rollback() and set_transaction_isolation(). We just need a list of what psycopg should or should not do. federico -- Federico Di Gregorio fog-NGVKUo/i/[email protected] God is real. Unless declared integer. -- Anonymous FORTRAN programmer _______________________________________________ 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/ iEYEARECAAYFAkuwUzMACgkQvcCgrgZGjevLQwCdFrLlM3qOn8co8m6sWgQiu5gr klMAn2RdQwHS6W7DSFsTM9k/YRj4fcNu =bsr1 -----END PGP SIGNATURE-----