[Twisted-web] Single-threaded WSGIResource

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Tue Feb 2 17:13:07 EST 2010

On 09:58 pm, cristiano.paris at gmail.com wrote:
>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:

Can you use a thread-local SQLite3 connection, or is that logic buried 
too deeply in some other code?

Another option (I think - untested) would be to give WSGIResource a 
different implementation of the thread pool interface:

class NotThreadPool:
    def callInThread(self, f, *a, **kw):
        f(*a, **kw)


More information about the Twisted-web mailing list