Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #61667

Re: Strange crashes

References <CA+FnnTwsx-AenOdnk3a2O4vfUgyuRcwpFb9to=q+kvQeXC5M_A@mail.gmail.com> <CAPTjJmoMbq_Cee-DWW8R+iNt80uNAB14u_m32PhPEQy=PW7-oA@mail.gmail.com>
Date 2013-12-11 21:47 -0800
Subject Re: Strange crashes
From Igor Korot <ikorot01@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3963.1386827623.18130.python-list@python.org> (permalink)

Show all headers | View raw


Hi, Chris,

On Wed, Dec 11, 2013 at 9:31 PM, Chris Angelico <rosuav@gmail.com> wrote:
> On Thu, Dec 12, 2013 at 4:25 PM, Igor Korot <ikorot01@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.

I was afraid to the answer like this. ;-)
The codebase is huge and it a lot of queries with connect/execute/disconnect.

So, when I find the culprit variable what do I do?
Make it a part of some class? Protect it with mutex?

How to solve this? And most importantly, how do _I_ verify that its solved?

Thank you.

>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Strange crashes Igor Korot <ikorot01@gmail.com> - 2013-12-11 21:47 -0800

csiph-web