MCPcopy Index your code
hub / github.com/ipython/ipython / writeout_cache

Method writeout_cache

IPython/core/history.py:1067–1100  ·  view source on GitHub ↗

Write any entries in the cache to the database.

(self, conn: Optional[sqlite3.Connection] = None)

Source from the content-addressed store, hash-verified

1065
1066 @only_when_enabled
1067 def writeout_cache(self, conn: Optional[sqlite3.Connection] = None) -> None:
1068 """Write any entries in the cache to the database."""
1069 if conn is None:
1070 conn = self.db
1071
1072 with self.db_input_cache_lock:
1073 try:
1074 self._writeout_input_cache(conn)
1075 except sqlite3.IntegrityError:
1076 self.new_session(conn)
1077 print(
1078 "ERROR! Session/line number was not unique in",
1079 "database. History logging moved to new session",
1080 self.session_number,
1081 )
1082 try:
1083 # Try writing to the new session. If this fails, don't
1084 # recurse
1085 self._writeout_input_cache(conn)
1086 except sqlite3.IntegrityError:
1087 pass
1088 finally:
1089 self.db_input_cache = []
1090
1091 with self.db_output_cache_lock:
1092 try:
1093 self._writeout_output_cache(conn)
1094 except sqlite3.IntegrityError:
1095 print(
1096 "!! Session/line number for output was not unique",
1097 "in database. Output will not be stored.",
1098 )
1099 finally:
1100 self.db_output_cache = []
1101
1102
1103if hasattr(os, "register_at_fork"):

Callers 6

end_sessionMethod · 0.95
get_tailMethod · 0.95
runMethod · 0.45
test_historyFunction · 0.45

Calls 3

_writeout_input_cacheMethod · 0.95
new_sessionMethod · 0.95