The big picture: I want to use the eventlet in some application that performs asynchronous I / O while working with Django models from the outside. Working with Django is externally simple (see Django: how can I use model classes to interact with my database from outside Django? ), But this is not the main problem.
I assume (I have not tested) that using Django from greens is dangerous. In fact, in the case of psycopg2, this is a warning (see http://www.initd.org/psycopg/docs/advanced.html#support-to-coroutine-libraries ):
Psycopg ties are not green. The thread is safe and cannot be used simultaneously by different green threads.
Django has one db connection per stream (right?), And as such, this can lead to scary scenarios when using them. Is it possible to somehow connect the connection object? Or make it "greenlet-local"?
My motivation is to use the connection pool from eventlet ( http://eventlet.net/doc/modules/db_pool.html ) to speed up my IO related application.
database django concurrency django-models eventlet
thinred
source share