Based on this great answer by zzzeek, I would like to use SQLAlchemy + PostgreSQL with gevent.
My problem is that I don't know what is an up-to-date PostgreSQL driver for such scenario.
Before I always used psycopg2, as I found it to be extremely stable and reliable.
My problem is that if I understand right psycopg2 needs to be monkey-patched to work under gevent, right? And the only way to do it is to use psycogreen, a project whose latest PyPi release is from 2012, has not been updated since 2015 and doesn't support Python 3.
How do you use SQLAlchemy in a concurrent way today? Is it simply not possible?
extensions.set_wait_callback(gevent_wait_callback) def gevent_wait_callback(conn, timeout=None): """A wait callback useful to allow gevent to work with Psycopg.""" while 1: state = conn.poll() if state == extensions.POLL_OK: break elif state == extensions.POLL_READ: wait_read(conn.fileno(), timeout=timeout) elif state == extensions.POLL_WRITE: wait_write(conn.fileno(), timeout=timeout) else: raise psycopg2.OperationalError( "Bad result from poll: %r" % state) And this happens to be the exact same snippet as is included in the official psycopg2_pool.py.
https://github.com/gevent/gevent/blob/master/examples/psycopg2_pool.py#L19
So this really should work under Py 3, as there is absolutely nothing Py 2 specific in there, at least I cannot see any.
Now to integrate it with Pyramid, can anyone recommend some snippet or Github example project where I can see some reference implementation?
All I found online was this 5 year old project integrating Gevent/SQLAlchemy/Flask/psycopg.
https://github.com/kljensen/async-flask-sqlalchemy-example