Re: In re: improving async support in psycopg
Manlio Perillo <[email protected]> Wed, 31 Mar 2010 13:40:56 +0200
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
Alexander Sabourenkov ha scritto: > Hello. > > I have already done a similar work, though much more invasive and > resulting in what amounts to a fork of psycopg2. > > Most code changes were in pqpath.c. Although my coroutine/event-loop > library is quite different from the gevent, general principles are same > and I hope one can find some insights on how it's done. > I think this is not how async support should be implemented. It is too invasive. Instead psycopg should just provide a *minimal* API (like libpq) to allow external applications to take advantage of an asynchronous environment. If you want a connection that it is always async, you can write a Python wrapper on the top of psycopg. It should not be hard to write a custom SQLAlchemy dialect, too. How a socket is checked for ready status should not be done in the psycopg implementation, it should be done by external applications (and using greenlets and an standard event/reactor API, you can write a flexible and reusable wrapper). Manlio