Re: Async support refactoring

Manlio Perillo <[email protected]> Fri, 23 Apr 2010 22:32:06 +0200
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
Daniele Varrazzo ha scritto:
> Hello,
> 
> I have merged Jan's support to async connections with the green
> branch: the result is probably the best async support among the Python
> database drivers. Here is a quick review of what I've done for use to
> everybody dealing with psycopg source code.
> 
> [...] 
> Any feedback is appreciated. Regards.
> 

First of all, thanks for your work!

Here are a few personal considerations:

1) I like the async branch, since it is very generic API.
   It can be used on frameworks like Twisted, or using greenlets.

   I have only one doubt: can the async API be accessed by C code?
   This is rather important for me, since if there is a C API, I can
   implement event handling entirely in C, for my WSGI implementation
   for Nginx.

2) I don't like the green branch.
   The reason is that the wait_select callback is supposed to block the
   current thread.

   In case greenlets are used, it will only block the current green
   thread.  But the problem is that the API is quite limited, it can not
   be used with a normal events API (like Twisted).

   Instead, if one want to use greenlets, this can be done on top of the
   async branch.

   The green branch is useful since it will "magically" allow to use the
   the normal DBAPI2 implementation in an asynchronous application, but
   I usually don't like the idea.


Manlio