##// END OF EJS Templates
HistoryManager.disabled -> HistoryManager.enabled
MinRK -
Show More
@@ -56,7 +56,7 b' class DummyDB(object):'
56 56 @decorator
57 57 def needs_sqlite(f, self, *a, **kw):
58 58 """return an empty list in the absence of sqlite"""
59 if sqlite3 is None or self.disabled:
59 if sqlite3 is None or not self.enabled:
60 60 return []
61 61 else:
62 62 return f(self, *a, **kw)
@@ -84,10 +84,11 b' class HistoryAccessor(Configurable):'
84 84
85 85 """)
86 86
87 disabled = Bool(False, config=True,
88 help="""disable the SQLite history
87 enabled = Bool(True, config=True,
88 help="""enable the SQLite history
89 89
90 If True there will be no stored history, no SQLite connection,
90 set enabled=False to disable the SQLite history,
91 in which case there will be no stored history, no SQLite connection,
91 92 and no background saving thread. This may be necessary in some
92 93 threaded environments where IPython is embedded.
93 94 """
@@ -135,9 +136,9 b' class HistoryAccessor(Configurable):'
135 136 # No one has set the hist_file, yet.
136 137 self.hist_file = self._get_hist_file_name(profile)
137 138
138 if sqlite3 is None and not self.disabled:
139 if sqlite3 is None and self.enabled:
139 140 warn("IPython History requires SQLite, your history will not be saved\n")
140 self.disabled = True
141 self.enabled = False
141 142
142 143 if sqlite3 is not None:
143 144 DatabaseError = sqlite3.DatabaseError
@@ -174,7 +175,7 b' class HistoryAccessor(Configurable):'
174 175
175 176 def init_db(self):
176 177 """Connect to the database, and create tables if necessary."""
177 if self.disabled:
178 if not self.enabled:
178 179 self.db = DummyDB()
179 180 return
180 181
@@ -433,7 +434,7 b' class HistoryManager(HistoryAccessor):'
433 434 self.save_flag = threading.Event()
434 435 self.db_input_cache_lock = threading.Lock()
435 436 self.db_output_cache_lock = threading.Lock()
436 if not self.disabled and self.hist_file != ':memory:':
437 if self.enabled and self.hist_file != ':memory:':
437 438 self.save_thread = HistorySavingThread(self)
438 439 self.save_thread.start()
439 440
@@ -669,11 +670,11 b' class HistorySavingThread(threading.Thread):'
669 670 the cache size reaches a defined threshold."""
670 671 daemon = True
671 672 stop_now = False
672 disabled = False
673 enabled = True
673 674 def __init__(self, history_manager):
674 675 super(HistorySavingThread, self).__init__()
675 676 self.history_manager = history_manager
676 self.disabled = history_manager.disabled
677 self.enabled = history_manager.enabled
677 678 atexit.register(self.stop)
678 679
679 680 @needs_sqlite
General Comments 0
You need to be logged in to leave comments. Login now