I am using ipdb debugger to debug multithreaded web applications locally (Django, Plone). Often ipdb seems to get confused because of the autoreload which happens when I am on the debug prompt. The resulting stack trace comes up
/Users/mikko/code/xxxx/venv/lib/python2.7/site-packages/IPython/core/history.pyc in writeout_cache(self, conn)
605 with self.db_input_cache_lock:
606 try:
--> 607 self._writeout_input_cache(conn)
608 except sqlite3.IntegrityError:
609 self.new_session(conn)
/Users/mikko/code/xxxx/venv/lib/python2.7/site-packages/IPython/core/history.pyc in _writeout_input_cache(self, conn)
589 for line in self.db_input_cache:
590 conn.execute("INSERT INTO history VALUES (?, ?, ?, ?)",
--> 591 (self.session_number,)+line)
592
593 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 4546363392 and this is thread id 140735211872640
After this, either the program cannot be closed (hanging threads) or ipdb itself stops working.
Is there a way to migitate this issue with ipdb and make it more multi-thread / autoreload safe?
EDIT: Clarified the question a bit, as I believe this might be underlying IPython issues. There could be some kind of workaround with making IPython simply discard history on the reload or disabling problematic IPython SQLite writes some other way.
ipython
, and if I useipdb
, while running the python file inipython
, will ipdb automatically reload statements in the python file, when usingn
,j
etc? – Eldridgeeldritch