ipdb,多线程和自动加载程序导致ProgrammingError

Mik*_*maa 6 python sqlite ipython pdb ipdb

我正在使用ipdb调试器在本地调试多线程Web应用程序(Django,Plone).由于我在调试提示符时发生的自动重载,ipdb似乎常常感到困惑.产生的堆栈跟踪出现了

    /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
Run Code Online (Sandbox Code Playgroud)

在此之后,程序无法关闭(挂起线程)或ipdb本身停止工作.

有没有办法用ipdb迁移这个问题,并使其更安全多线程/自动重载?

编辑:稍微澄清了一下这个问题,因为我认为这可能是IPython问题的根本原因.可能存在某种解决方法,使得IPython只是在重新加载时丢弃历史记录或禁用有问题的IPython SQLite以其他方式写入.

ist*_*tib 5

您始终可以在单线程模式下运行Django

python manage.py runserver --nothreading
Run Code Online (Sandbox Code Playgroud)