##// END OF EJS Templates
Move with statement so history db cache is written out in one transaction (two if output history is being logged).
Thomas Kluyver -
Show More
@@ -411,14 +411,14 b' class HistoryManager(Configurable):'
411 self.writeout_cache()
411 self.writeout_cache()
412
412
413 def _writeout_input_cache(self):
413 def _writeout_input_cache(self):
414 for line in self.db_input_cache:
414 with self.db:
415 with self.db:
415 for line in self.db_input_cache:
416 self.db.execute("INSERT INTO history VALUES (?, ?, ?, ?)",
416 self.db.execute("INSERT INTO history VALUES (?, ?, ?, ?)",
417 (self.session_number,)+line)
417 (self.session_number,)+line)
418
418
419 def _writeout_output_cache(self):
419 def _writeout_output_cache(self):
420 for line in self.db_output_cache:
420 with self.db:
421 with self.db:
421 for line in self.db_output_cache:
422 self.db.execute("INSERT INTO output_history VALUES (?, ?, ?)",
422 self.db.execute("INSERT INTO output_history VALUES (?, ?, ?)",
423 (self.session_number,)+line)
423 (self.session_number,)+line)
424
424
@@ -432,7 +432,7 b' class HistoryManager(Configurable):'
432 "database. History logging moved to new session",
432 "database. History logging moved to new session",
433 self.session_number)
433 self.session_number)
434 try: # Try writing to the new session. If this fails, don't recurse
434 try: # Try writing to the new session. If this fails, don't recurse
435 self.writeout_cache()
435 self._writeout_input_cache()
436 except sqlite3.IntegrityError:
436 except sqlite3.IntegrityError:
437 pass
437 pass
438 finally:
438 finally:
General Comments 0
You need to be logged in to leave comments. Login now