How are synchronous views handled by Django's ASGI application?

My team is having a discussion around using WSGI vs ASGI servers. One thing we do not know yet is how synchronous django views are handled by an ASGI server. We understand that async views will be executed in the event loop, but how are synchronous views handled by the ASGI application object? Are they also executed on the event loop or is there a separate thread to handle these views?

1 Like

Sync views, and middleware, will be executed in a sync thread pool.

This is somewhat documented here: Asynchronous support | Django documentation | Django

Django handles the bridging back and forth between styles for you with the asgiref async adapter functions

Thanks for the quick response. Is there any documentation on how this thread pool works? For example, if sync views are placed 1:1 onto threads?

The only documentation is what I’ve pointed you at. You can otherwise see the asgiref source - it’s not too big.