On Fri, Jun 4, 2010 at 7:16 AM, afrotypa <[email protected]> wrote: > Hi All, > > > For a while I have been toying with the idea of developing/running a > database (postgresql backend) driven WSGI app using an async python > WSGI server such as gevent. > > Now that the newer psycopg2 (>=2.2.0) drivers provide coroutine > support (via a hook which makes c extension database drivers co- > routine friendly) I am looking to try gevent out as soon as I can > figure out how to integrate gevent and sqlalchemy. > > In theory it should be possible to run blocking SQLAlchemy queries in > a spawned greenlet using an async DB API 2.0 driver such as psycopg2. > Blocking only the greenlet handling the specific request. > > See the following URL for details of coroutine support in psycopg2:- > > http://bitbucket.org/dvarrazzo/psycogreen/wiki/Home > > An example of a wait call back implementation for gevent is here :- > > http://bitbucket.org/dvarrazzo/psycogreen/src/tip/gevent/psyco_gevent.py > > My question is what is a good pattern for using SQLAlchemy with a co- > routine library such as gevent in a pylons based WSGI app.? > > For starters how do I configure the SQLAlchemy connection pool to > create async connections only?. > > i.e. > > Write a custom getconn method and passing async=True to > psycopg2.connect? > > Or > > pass connect_args to create_engine?. > > Assuming gevent spawns a greenlet to handle each WSGI request, I think > SQLAlchemy should just work as usual in this situation, since the > scopedSession would ensure that a different SQLAlchemy session is used > for each request. Is this a reasonable assumption to make about this?. > > If I wanted to run multiple independent queries (each in its own > greenlet) in the same pylons request, it appears I would have to > explicitly create an sqlalchemy session for each greenlet instance in > this case. Is this the case? > > Am I missing something very important here? > > Hopefully someone here might be able to shed some more light into all > this. > > Thanks, > > Note: I already posted this question on pylons-discuss, but I am > thinking this is more an SQLAlchemy than a pylons question. > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > >
I would also love to know the answer to this question! Also interested in other libraries like those for mysql (gevent-mysql). -- Yang Zhang http://yz.mit.edu/ -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
