Re: improving async support in psycopg
Daniele Varrazzo <[email protected]> Sun, 28 Mar 2010 03:10:52 +0100
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Mar 28, 2010 at 2:35 AM, Daniele Varrazzo <[email protected]> wrote: > On Sat, Mar 27, 2010 at 2:40 AM, Jan UrbaĆski <[email protected]> wrote: > >> Skimming over the patches I have a question: is it really necessary to add >> the callback feature into the C library? AFAICS the callback is executed on >> asynchronous cursors everytime there is a execute() attempt. Couldn't you >> just write a Python psycopg2.extensions.cursor subclass that overrides >> execute() by calling that callback? > > As things are now, execute and callproc being the only methods using > async features, this is the case. Probably it will be too extending > support to other currently blocking methods (begin/commit/rollback > etc). > > Yes, it is probably the case to think about Python subclasses to add a > wait wrapper around async methods. the psycopg.extras module could > provide such wrappers exposing a method, equivalent to the callback in > my test, to be customized by async libraries to fit their framework. 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. -- Daniele _______________________________________________ Psycopg mailing list [email protected] http://lists.initd.org/mailman/listinfo/psycopg