Some testing material to work with Psycopg2 with coroutine support.
One upcoming Psycopg version will have coroutine support. In order to use them a coroutine framework, such as Eventlet or gevent, should implement a "wait callback" as an hook to schedule a coroutine switch while a libpq call is waiting for data.
In this project there are wait callback implementations for a few coroutine libraries: they are licensed in order to allow their inclusion in the library.
You can check out the Psycopg green branch from its GIT repository.