This is instead of the commit we reverted in the previous commit.
The problem is that django keeps the connection per thread and it relies
on django itself to clean them up before/after connections.
We can't do this, because django is unaware of fastapi, so we have to
manage this ourselves.
The easiest way is to call it at the beginning of evenry route and every dep.
We need to do it for each because unfortunately fastapi may send them to
different worker threads.
This ended up being useless because of the way startlette and fastapi do
thread pools. The middleware is called in one thread, the path in
another, and the dependency in yet another.
This reverts commit 473448246f.
The code uses the django ORM which is sync, and fastapi handles sync paths
just fine. So having all of this extra code for handling async was unnecessary.
* Changed link to wiki
* Removed unneeded links (as uWSGI won't be supported)
* Added --host flag to uvicorn command, as the server is only accessible from the host machine otherwise (and not from another in the local network)
FastAPI is much faster (twice as fast in our testing environment), though
more importantly it's much faster to develop with, much less error-prone
thanks to strong typing, and makes it easier to further extend the server.
We currently still use the Django ORM behind the scenes, which means we still
get all of the benefits of the django admin UI, and being able to use django
for the non-API parts.
Merge of #72