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


Groups > comp.lang.python > #61662 > unrolled thread

Re: Strange crashes

Started byChris Angelico <rosuav@gmail.com>
First post2013-12-12 16:31 +1100
Last post2013-12-12 00:52 -0500
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Strange crashes Chris Angelico <rosuav@gmail.com> - 2013-12-12 16:31 +1100
    Re: Strange crashes Roy Smith <roy@panix.com> - 2013-12-12 00:52 -0500

#61662 — Re: Strange crashes

FromChris Angelico <rosuav@gmail.com>
Date2013-12-12 16:31 +1100
SubjectRe: Strange crashes
Message-ID<mailman.3961.1386826313.18130.python-list@python.org>
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.

ChrisA

[toc] | [next] | [standalone]


#61666

FromRoy Smith <roy@panix.com>
Date2013-12-12 00:52 -0500
Message-ID<roy-6794AA.00524612122013@news.panix.com>
In reply to#61662
In article <mailman.3961.1386826313.18130.python-list@python.org>,
 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?

One thing you might try is having your program print out the names and 
ids of all the threads.  Something like:

for t in threading.enumerate():
   print t.ident, t.name

If you're lucky, you might get some clue as to what each thread is doing 
from its name.  Or, it may not give you any useful information at all.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web