I have zero trust in this code and I have been bitten by fixes to this library that introduced deadlocks in my own code.
[1] https://github.com/django/asgiref#synchronous-code--threads.
[2] https://github.com/django/asgiref/blob/main/asgiref/sync.py#...
Is there anything else in Python-land you would go with for the use case you have in mind? Or does pretty much all the async stuff turn on you like this, at some point or another?
- pick a mature ASGI server
- pick a framework and libraries that have been designed from the start with async in mind. Be suspicious of libraries that support sync and async APIs without clear guard rails between the too implementations
- avoid setups where you have multiple event loops in a single process.
I have 7 YoE with Django. Its great at so many things. You see some code, like middlewares, and immediately understand what's going on.
Now, we also have Starlette. The base of all new, fancy asgi libraries. Here's the base middleware class.
https://github.com/encode/starlette/blob/8d7a1cacfb3e1a30cbb...
In the last couple of years I heard 'we're running fastapi on production. Wanna join us?' so many times... but the reality is that it's still not suitable for prod. Who wants to work with a code like that if you have a readable, stable Django? I'm clueless.
I'm using internal pools + pgbouncer but as I write this out I am beginning to wonder if that is even necessary.
[0] http://www.pgbouncer.org/features.html#fn:2