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

1,183 views
Skip to first unread message

Dan Shechter

unread,
Oct 13, 2012, 11:01:48 AM10/13/12
to we...@googlegroups.com
Hi All,

I have a library which is using sqlite, and I want to use it inside my web.py server.

When trying to use sqlite I get the following error:

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

Any ideas what to do?

Thanks,
Dan

Dan Shechter

unread,
Oct 13, 2012, 11:05:06 AM10/13/12
to we...@googlegroups.com
The hole error is:

ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 2101933056 and this is thread id -2085557248

Segmentation fault (core dumped) 

Dan Shechter

unread,
Oct 13, 2012, 11:16:42 AM10/13/12
to we...@googlegroups.com
This is turning into a blog... I found a workaround but I would like to understand why it failed in the first place.

The workaround was to recreate the object holding the sqlite object each time before issuing a function which uses sqlite. Its ugly, but it works.


On Saturday, October 13, 2012 5:01:48 PM UTC+2, Dan Shechter wrote:

Andrey Kuzmin

unread,
Oct 13, 2012, 12:52:16 PM10/13/12
to we...@googlegroups.com
If your library is not thread safe, then you may init object in application processor and store it in web.ctx. http://webpy.org/cookbook/application_processors

Dan Shechter

unread,
Oct 14, 2012, 11:57:40 PM10/14/12
to we...@googlegroups.com
Thanks! It worked!
Reply all
Reply to author
Forward
0 new messages