Hacker News new | past | comments | ask | show | jobs | submit login

I'd add that crucially, DB ORM operations just work with gevent. It will be a while before async database operations are supported natively by Django. For me that is a complete blocker.



> DB ORM operations just work with gevent

My impression was that django+gevent requires some care for the db part. The psycopg2 docs state, for instance

"Psycopg connections are not green thread safe and can’t be used concurrently by different green threads." [1,2].

In addition, gevent cannot monkey patch psycopg2 code because it is C and not python. This is handled by calling psycopg2.extensions.set_wait_callback() [1,3,4]

I just now realize that you're probably referring to making the ORM itself async capable which is on the roadmap https://code.djangoproject.com/wiki/AsyncProject in which case I totally agree.

[1] https://www.psycopg.org/docs/advanced.html#support-for-corou... [2] https://stackoverflow.com/questions/12650048/how-can-i-pool-... [3] https://github.com/gevent/gevent/blob/master/examples/psycop... [4] https://github.com/psycopg/psycogreen


In practice this is just a one-time setup. We use https://github.com/jneight/django-db-geventpool which uses psycogreen under the hood. It isn't perfect (we're currently tracking down some rare cases where connections aren't properly returning to the pool, though we believe this to be error on our side) but it's more than sufficient.

While making the ORM async capable would be great, I'm not sure it will ever make sense to migrate towards sprinkling "async" explicitly across our codebase. We'll see, of course.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: