Basically, WSGI is not internally incompatible with asynchronous program design; in fact, PEP 333 goes a considerable length to indicate how servers, applications, and middleware should work to support these kinds of things.
At the heart of this is the return of the iterator to the container. Each time asynchronous wsgi app_iter is called, it checks all its pending asynchronous tasks (database connections, etc.), and if any of them has data, app_iter gives some data; otherwise, it produces an empty string. To support this, the wsgi container will have to keep track of all requests in flight, and iterate through each one of them in order to get more data, in addition to servicing any other deferred work for which it is responsible.
Basically, very few wsgi applications or frameworks actually do this. almost always, wsgi frameworks are blocked for various reasons; reading files from disk or loading data from the database for any reason at all (most ORMs make this problem difficult.) The wsgi twisted container works under the assumption that since some wsgi applications are blocked, it is possible that any wsgi application can be blocked and therefore always runs them in a stream.
There are two things you can do; either explore your own twisted web structure, which is strong enough; or consider creating a wsgi wrapper to twist outside your own twisted container. Making sure that the wsgi application is actually asynchronous is certainly a prerequisite of the latter, but wsgi itself is pretty simple, a thin shell on top of http, and therefore it should be fairly light.
SingleNegationElimination
source share