Re: improving async support in psycopg
Jan Urbański <[email protected]> Fri, 26 Mar 2010 16:36:39 +0100
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
Daniele Varrazzo wrote: > On Fri, Mar 26, 2010 at 2:58 PM, Jan Urbański <[email protected]> wrote: >> You can always issue your DECLARE CURSOR and FETCH FROM calls yourself. >> For instance, to really use async connections you will have to turn off >> the psycopg2 transaction management and issue BEGIN and COMMIT yourself, >> because currently they both are blocking. > > Oh, I haven't notice that. Can't they be handled using the same async machinery? It's possible, you would only have to add a select() loop after begin/commit and use conn.poll() after doing rollback(). Also, psycopg2 issues a BEGIN for you when you first do an execute() after a commit(), so we'd have to use the same trick the connection class uses currently, issue the BEGIN asynchronously and only after it returns execute the user's code. Possible, although a bit complex. Federico suggested that a nice property of psycopg2 connections is that you can always issue a rollback() and get the connection back into a workable state. With async ROLLBACK that would no longer be the case. I'm torn on whether ROLLBACK should always be sync, whether there should be an argument on rollback() that specifies if you want to block on it, or something still different should happen... Cheers, Jan _______________________________________________ Psycopg mailing list [email protected] http://lists.initd.org/mailman/listinfo/psycopg