Re: (long) improving async support in psycopg

Daniele Varrazzo <[email protected]> Wed, 24 Mar 2010 14:36:37 +0000
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On Wed, Mar 24, 2010 at 12:19 PM, Jan Urbański <[email protected]> wrote:
> Daniele Varrazzo wrote:

>  A dbapi interface (thus without the extra `cursor.execute()`
>> parameter) would also enable the async psycopg to be used with
>> existing clients, e.g. SQLAlchemy.
>
> I'm not sure I follow: how would SQLAlchemy use the async API? I think
> the user needs to be aware that he's using the async features, so he
> will do select calls (like Twisted) or will yield control on EAGAIN
> errors from the socket (like eventlet).

In case eventlet is used, the single coroutine can get blocked by an
execute: while it is blocked, control is yield to a different
coroutine. From the PoV of the single coroutine the semantic would be
the same of a blocking `execute()`, so SQLAlchemy can be used. How to
obtain this? I was thinking about something along the line of
providing an hook on the connection or on the module (for newly
created connections) that e.g. eventlet could use to install the
connection file descriptor into the libevent reactor
(http://www.gevent.org/gevent.core.html) and enable switching on
block. I think other coroutine-based framework may use the same hook,
provided they expose a way to hook a fd into the select/poll/whatever
but I don't know if twisted+deferred would fit this model.

-- Daniele
_______________________________________________
Psycopg mailing list
[email protected]
http://lists.initd.org/mailman/listinfo/psycopg