I'm playing with Django (1.1.1) under Twisted Web (9.0.0) through the
WSGI interface. When using my web app under the test server with
sqlite3 as the DBMS, I'm having troubles since in-memory sqlite3 DBs
can't be shared among threads.
The solution I came up with was to run the WSGIResource in the main
thread. In order to do so, I subclassed the WSGIResource as follows:
from twisted.web.wsgi import WSGIResource,_WSGIResponse
from twisted.web.server import NOT_DONE_YET
response = _WSGIResponse(
self._reactor, self._threadpool, self._application, request)
Basically, I replaced "response.start()" in the original render()
method with the "response.run()", bypassing the callInThread() call in
the _WSGIResponse's start() method. Even if it works, I hate importing
_WSGIResponse and replicating the code of the original WSGIResource's
render() code. Anyhow, I can't think of a better/more elegant solution
with the current implementation.
I'll appreciate any comment on this.