Strange crashes

Chris Angelico rosuav at gmail.com
Thu Dec 12 06:31:50 CET 2013


On Thu, Dec 12, 2013 at 4:25 PM, Igor Korot <ikorot01 at gmail.com> wrote:
> ProgrammingError: SQLite objects created in a thread can only be used
> in that same thread.The object was created in thread id 14260 and this
> is thread id 9264
>
> Where should I start looking for causes?

Well, I'd look for something that creates an SQLite object on one
thread and uses it on another :)

More generally, your issue is probably due to sharing things across
threads that shouldn't be shared. That's going to give all sorts of
race conditions that you might never be able to replicate - the exact
order of operations might depend on any number of factors, even stuff
you wouldn't expect to have ANY significance like the speed of your
hard drive. The fact that it works on your system is indicative of
luck.

See if you can avoid *any* mutable globals in your thread handlers, or
if you can't achieve that, have a good hard look at every global that
any thread other than the main thread can change. The less you have to
look at, the easier it'll be to find this sort of thing.

ChrisA



More information about the Python-list mailing list