3

I'm relatively new to application development but here goes nothing.

I've been working on a project that employs the use of a Tornado server and SQLAlchemy's ORM for database management/access (using postgres in the back end).

At the outset of the project I hadn't considered the possibility that using SQLAlchemy would prevent me from taking advantage of Tornado's async features (since SQLAlchemy's database calls apparently 'block' the thread).

Do you have any suggestions as to how to implement an async-compatible setup with Tornado+SQLA+postgres?

Mitch
  • 133
  • 7
  • possible duplicate of [How to make SQLAlchemy in Tornado to be async?](http://stackoverflow.com/questions/16491564/how-to-make-sqlalchemy-in-tornado-to-be-async) – van Aug 08 '13 at 05:04
  • possible duplicate of [Can SQLAlchemy be configured to be non-blocking?](http://stackoverflow.com/questions/10214042/can-sqlalchemy-be-configured-to-be-non-blocking) – van Aug 08 '13 at 05:05

1 Answers1

2

Take a look at aiopg - https://github.com/aio-libs/aiopg

It is a Python 3.4 asyncio adapter for postgres that includes sqlalchemy support. I haven't tried it myself yet, but found it while looking for async libraries for postgres and tornado. I am using Momoko, but it only supplies the raw psycopg2 layer.

Remember that the latest version of Tornado supports asyncio, so asyncio libraries will now work with Tornado.

Michael Robellard
  • 2,268
  • 15
  • 25