##// END OF EJS Templates
Use check_same_thread=False by default for history sqlite db (#13886)...
Use check_same_thread=False by default for history sqlite db (#13886) I had run into the following exception while trying to use IPython in a thread: ``` Traceback (most recent call last): File "/usr/local/lib/python3.11/dist-packages/IPython/core/interactiveshell.py", line 3745, in atexit_operations self._atexit_once() File "/usr/local/lib/python3.11/dist-packages/IPython/core/interactiveshell.py", line 3728, in _atexit_once self.history_manager.end_session() File "/usr/local/lib/python3.11/dist-packages/IPython/core/history.py", line 576, in end_session self.writeout_cache() File "/usr/local/lib/python3.11/dist-packages/decorator.py", line 232, in fun return caller(func, *(extras + args), **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/IPython/core/history.py", line 60, in only_when_enabled return f(self, *a, **kw) ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/dist-packages/IPython/core/history.py", line 831, in writeout_cache self._writeout_input_cache(conn) File "/usr/local/lib/python3.11/dist-packages/IPython/core/history.py", line 812, in _writeout_input_cache with conn: sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 139673788811008 and this is thread id 139673823184704. ``` And discovered that an issue (#680) has been open for it since 2011. Back in [2012](https://github.com/ipython/ipython/issues/680#issuecomment-3444922), it seems like the only reason not to fix it was that the parameter `check_same_thread` was not documented, but now [it is](https://docs.python.org/3.11/library/sqlite3.html#sqlite3.connect), and it has been at least since [3.6](https://docs.python.org/3.6/library/sqlite3.html#sqlite3.connect). Note that according to the docs: > check_same_thread ([bool](https://docs.python.org/3/library/functions.html#bool)) – If True (default), only the creating thread may use the connection. If False, the connection may be shared across multiple threads; if so, write operations should be serialized by the user to avoid data corruption. But I don't think this is an issue here. The operations should be synchronized by the user only *on the same connection object*, and if I'm not mistaken, if two instances of IPython were started in separate threads, they'd each have their own history manager with its own connection. The exception above (and the one in the related issue) is raised from `atexit`, when the main thread is running finalizations registered by other threads. At that point, the operations are serial anyway because they are executed in a single thread.

File last commit:

r27588:1c763ce9
r28320:2da6fb98 merge
Show More
links.txt
97 lines | 4.0 KiB | text/plain | TextLexer
.. This (-*- rst -*-) format file contains commonly used link targets
and name substitutions. It may be included in many files,
therefore it should only contain link targets and name
substitutions. Try grepping for "^\.\. _" to find plausible
candidates for this list.
NOTE: this file must have an extension *opposite* to that of the main reST
files in the manuals, so that we can include it with ".. include::"
directives, but without triggering warnings from Sphinx for not being listed
in any toctree. Since IPython uses .txt for the main files, this one will
use .rst.
NOTE: reST targets are
__not_case_sensitive__, so only one target definition is needed for
ipython, IPython, etc.
NOTE: Some of these were taken from the nipy links compendium.
.. Main IPython links
.. _ipython: https://ipython.org
.. _`ipython manual`: https://ipython.org/documentation.html
.. _ipython_github: http://github.com/ipython/ipython/
.. _nbviewer: http://nbviewer.ipython.org
.. _ZeroMQ: http://zeromq.org
.. Documentation tools and related links
.. _graphviz: http://www.graphviz.org
.. _Sphinx: http://sphinx.pocoo.org
.. _`Sphinx reST`: http://sphinx.pocoo.org/rest.html
.. _sampledoc: http://matplotlib.org/sampledoc
.. _reST: http://docutils.sourceforge.net/rst.html
.. _docutils: http://docutils.sourceforge.net
.. _lyx: http://www.lyx.org
.. _pep8: https://peps.python.org/pep-0008/
.. Licenses
.. _GPL: http://www.gnu.org/licenses/gpl.html
.. _BSD: http://www.opensource.org/licenses/bsd-license.php
.. _LGPL: http://www.gnu.org/copyleft/lesser.html
.. Other python projects
.. _numpy: http://numpy.scipy.org
.. _scipy: http://www.scipy.org
.. _scipy_conference: http://conference.scipy.org
.. _matplotlib: http://matplotlib.org
.. _pythonxy: https://code.google.com/p/pythonxy/
.. _ETS: http://code.enthought.com/projects/tool-suite.php
.. _EPD: http://www.enthought.com/products/epd.php
.. _python: http://www.python.org
.. _mayavi: http://code.enthought.com/projects/mayavi
.. _sympy: http://code.google.com/p/sympy
.. _sage: http://sagemath.org
.. _pydy: http://code.google.com/p/pydy
.. _vpython: http://vpython.org
.. _cython: http://cython.org
.. _software carpentry: http://software-carpentry.org
.. Not so python scientific computing tools
.. _matlab: http://www.mathworks.com
.. _VTK: http://vtk.org
.. Other organizations
.. _enthought: http://www.enthought.com
.. _kitware: http://www.kitware.com
.. _netlib: http://netlib.org
.. Other tools and projects
.. _indefero: http://www.indefero.net
.. _git: http://git-scm.com
.. _github: http://github.com
.. _Markdown: http://daringfireball.net/projects/markdown/syntax
.. _Running Code in the IPython Notebook: notebook_p1_
.. _notebook_p1: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%25201%2520-%2520Running%2520Code.ipynb
.. _Basic Output: notebook_p2_
.. _notebook_p2: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%202%20-%20Basic%20Output.ipynb
.. _Plotting with Matplotlib: notebook_p3_
.. _notebook_p3: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%203%20-%20Plotting%20with%20Matplotlib.ipynb
.. _Markdown Cells: notebook_p4_
.. _notebook_p4: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%204%20-%20Markdown%20Cells.ipynb
.. _Rich Display System: notebook_p5_
.. _notebook_p5: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Part%205%20-%20Rich%20Display%20System.ipynb
.. _notebook_custom_display: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Custom%20Display%20Logic.ipynb
.. _Frontend/Kernel Model: notebook_two_proc_
.. _notebook_two_proc: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Frontend-Kernel%20Model.ipynb
.. _Cell magics: notebook_cell_magics_
.. _notebook_cell_magics: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/1.x/examples/notebooks/Cell%20Magics.ipynb