MCPcopy Create free account
hub / github.com/ipython/ipython / writeout_cache

Method writeout_cache

IPython/core/history.py:773–802  ·  view source on GitHub ↗

Write any entries in the cache to the database.

(self, conn=None)

Source from the content-addressed store, hash-verified

771
772 @needs_sqlite
773 def writeout_cache(self, conn=None):
774 """Write any entries in the cache to the database."""
775 if conn is None:
776 conn = self.db
777
778 with self.db_input_cache_lock:
779 try:
780 self._writeout_input_cache(conn)
781 except sqlite3.IntegrityError:
782 self.new_session(conn)
783 print("ERROR! Session/line number was not unique in",
784 "database. History logging moved to new session",
785 self.session_number)
786 try:
787 # Try writing to the new session. If this fails, don't
788 # recurse
789 self._writeout_input_cache(conn)
790 except sqlite3.IntegrityError:
791 pass
792 finally:
793 self.db_input_cache = []
794
795 with self.db_output_cache_lock:
796 try:
797 self._writeout_output_cache(conn)
798 except sqlite3.IntegrityError:
799 print("!! Session/line number for output was not unique",
800 "in database. Output will not be stored.")
801 finally:
802 self.db_output_cache = []
803
804
805class HistorySavingThread(threading.Thread):

Callers 3

end_sessionMethod · 0.95
runMethod · 0.45
test_historyFunction · 0.45

Calls 3

_writeout_input_cacheMethod · 0.95
new_sessionMethod · 0.95

Tested by 1

test_historyFunction · 0.36