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