##// END OF EJS Templates
Updating comments and docstrings for history autosave.
Thomas Kluyver -
Show More
@@ -107,12 +107,13 b' class HistoryManager(object):'
107 # Fill the history zero entry, user counter starts at 1
107 # Fill the history zero entry, user counter starts at 1
108 self.store_inputs('\n', '\n')
108 self.store_inputs('\n', '\n')
109
109
110 # Autosave every 60 seconds:
110 # Create and start the autosaver.
111 self.autosave_flag = threading.Event()
111 self.autosave_flag = threading.Event()
112 self.autosave_timer = HistorySaveThread(self.autosave_flag, 60)
112 self.autosave_timer = HistorySaveThread(self.autosave_flag, 60)
113 self.autosave_timer.start()
113 self.autosave_timer.start()
114 # Register the autosave handler to be triggered as a post execute
115 # callback.
114 self.shell.register_post_execute(self.autosave_if_due)
116 self.shell.register_post_execute(self.autosave_if_due)
115 # Ensure that any autosave thread we start is stopped tidily.
116
117
117 def _init_shadow_hist(self):
118 def _init_shadow_hist(self):
118 try:
119 try:
@@ -272,14 +273,16 b' class HistoryManager(object):'
272 self.dir_hist[:] = [os.getcwd()]
273 self.dir_hist[:] = [os.getcwd()]
273
274
274 class HistorySaveThread(threading.Thread):
275 class HistorySaveThread(threading.Thread):
275 """This thread makes IPython save history periodically (the current default
276 """This thread makes IPython save history periodically.
276 is once per minute), so that it is not lost in the event of a crash. It also
277
277 allows the commands in the current IPython shell to be accessed in a newly
278 Without this class, IPython would only save the history on a clean exit.
278 started instance.
279 This saves the history periodically (the current default is once per
280 minute), so that it is not lost in the event of a crash.
279
281
280 This simply sets an event to indicate that history should be saved. The
282 The implementation sets an event to indicate that history should be saved.
281 actual save is carried out after executing a user command, to avoid
283 The actual save is carried out after executing a user command, to avoid
282 thread issues."""
284 thread issues.
285 """
283 daemon = True
286 daemon = True
284
287
285 def __init__(self, autosave_flag, time_interval=60):
288 def __init__(self, autosave_flag, time_interval=60):
@@ -295,7 +298,6 b' class HistorySaveThread(threading.Thread):'
295 self.exit_now.wait(self.time_interval)
298 self.exit_now.wait(self.time_interval)
296 if self.exit_now.is_set():
299 if self.exit_now.is_set():
297 break
300 break
298 #print("Setting flag for autosaving history...") # DEBUG
299 self.autosave_flag.set()
301 self.autosave_flag.set()
300
302
301 def stop(self):
303 def stop(self):
General Comments 0
You need to be logged in to leave comments. Login now