Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite objects created in a thread can only be used in that same thread #1505

Closed
santagada opened this issue Mar 16, 2012 · 1 comment
Closed
Milestone

Comments

@santagada
Copy link

This is an error I get when closing scrapy shell (that uses ipython), maybe its an issue with their code but either way:

ProgrammingError Traceback (most recent call last)
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/atexit.pyc in _run_exitfuncs()
22 func, targs, kargs = _exithandlers.pop()
23 try:
---> 24 func(_targs, *_kargs)
25 except SystemExit:
26 exc_info = sys.exc_info()

/Library/Python/2.6/site-packages/IPython/core/interactiveshell.pyc in atexit_operations(self)
2732 # this must be before the tempfile cleanup, in case of temporary

2733 # history db

-> 2734 self.history_manager.end_session()
2735
2736 # Cleanup all tempfiles left around

/Library/Python/2.6/site-packages/IPython/core/history.pyc in end_session(self)
428 def end_session(self):
429 """Close the database session, filling in the end time and line count."""
--> 430 self.writeout_cache()
431 with self.db:
432 self.db.execute("""UPDATE sessions SET end=?, num_cmds=? WHERE

/Library/Python/2.6/site-packages/IPython/core/history.pyc in writeout_cache(self, conn)

/Library/Python/2.6/site-packages/IPython/core/history.pyc in needs_sqlite(f, _a, *_kw)
59 return []
60 else:
---> 61 return f(a,*kw)
62
63 class HistoryAccessor(Configurable):

/Library/Python/2.6/site-packages/IPython/core/history.pyc in writeout_cache(self, conn)
602 with self.db_input_cache_lock:
603 try:
--> 604 self._writeout_input_cache(conn)
605 except sqlite3.IntegrityError:
606 self.new_session(conn)

/Library/Python/2.6/site-packages/IPython/core/history.pyc in _writeout_input_cache(self, conn)
586 for line in self.db_input_cache:
587 conn.execute("INSERT INTO history VALUES (?, ?, ?, ?)",
--> 588 (self.session_number,)+line)
589
590 def _writeout_output_cache(self, conn):

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

@takluyver
Copy link
Member

Thanks, but I think this is the same as issue #680. Scrapy is doing something odd with threads. There are some workarounds suggested on that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants