CCI-MOC / hil

Hardware Isolation Layer, formerly Hardware as a Service
Apache License 2.0
24 stars 54 forks source link

ProgrammingError: SQLite objects created in a thread can only be used in that same thread #391

Open henn opened 9 years ago

henn commented 9 years ago

Found this in the error log:

ERROR:sqlalchemy.pool.NullPool:Exception closing connection <sqlite3.Connection object at 0x7f779924f110>
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.9.7-py2.6-linux-x86_64.egg/sqlalchemy/pool.py", line 250, in _close_connection
    self._dialect.do_close(connection)
  File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.9.7-py2.6-linux-x86_64.egg/sqlalchemy/engine/default.py", line 412, in do_close
    dbapi_connection.close()
ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 140151755589376 and this is thread id 140151766079232
zenhack commented 9 years ago

Per conversation, we're being pretty sloppy with managing sessions in general; we should just do the session setup/teardown in our global request handler wrapper, and make it available as a request local.

zenhack commented 9 years ago

The other possibility here is just that hey, sqlite isn't actual thread safe (I'm pretty sure). We really need to make this work with postgres or mysql.