Threading error occurs with adbapi and SQLite

[email protected] Fri, 25 Sep 2009 00:56:58 -0000
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from mjcaley <None>:

An error occurs from sqlite3 when the reactor is stopped indicating that SQLite objects can only be used in the same thread.  Setting the check_same_thread parameter to False in the database connection does suppress this error.  Data is returned correctly until up until the reactor is stopped.

I was using revision 26354.

Output:

[(u'[email protected]', u'localhost', u'sha256:4672db5a9ff30d9b2d5c97bb9b1d1ea4bdf1262e6a5110b7f43defc4a6ea04db', 1, 1, 0, None, None, None, u'Administrator', None, None, None, u'Example Inc.', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None), (u'[email protected]', u'localhost', u'sha256:500c7694095af2f2e5b38b4d54b1b013e030c2ddb45510099d015bfcb5c35849', 1, 1, 0, u'Alice', None, u'Anderson', u'Alice Anderson', u'AA', u'CEO', u'Executive', u'Example Inc.', None, None, u'123 Here Ave.', u'Apt. 123', u'Appletown', u'A0A 0A0', u'Canada', None, None, None, None, None, None, u'(111) 111-1111', u'(222) 222-2222 x2222', None, None, None, None, None, None, None)]
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Twisted-8.2.0_r27354-py2.6-macosx-10.3-i386.egg/twisted/internet/defer.py", line 181, in addCallbacks
    self._runCallbacks()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Twisted-8.2.0_r27354-py2.6-macosx-10.3-i386.egg/twisted/internet/defer.py", line 323, in _runCallbacks
    self.result = callback(self.result, *args, **kw)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Twisted-8.2.0_r27354-py2.6-macosx-10.3-i386.egg/twisted/internet/base.py", line 410, in _continueFiring
    callable(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Twisted-8.2.0_r27354-py2.6-macosx-10.3-i386.egg/twisted/enterprise/adbapi.py", line 374, in finalClose
    self._close(conn)
--- <exception caught here> ---
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Twisted-8.2.0_r27354-py2.6-macosx-10.3-i386.egg/twisted/enterprise/adbapi.py", line 420, in _close
    conn.close()
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id -1341648896 and this is thread id -1610029280


----------
Type     : defect
Component: core
Keywords : 
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/4040