Show More
@@ -257,29 +257,24 b' class HistorySaveThread(threading.Thread):' | |||
|
257 | 257 | """Thread to save history periodically""" |
|
258 | 258 | daemon = True |
|
259 | 259 | |
|
260 |
def __init__(self, IPython_object, time_interval |
|
|
260 | def __init__(self, IPython_object, time_interval): | |
|
261 | 261 | threading.Thread.__init__(self) |
|
262 | 262 | self.IPython_object = IPython_object |
|
263 | 263 | self.time_interval = time_interval |
|
264 |
self.exit_now = |
|
|
265 | self.cond = threading.Condition() | |
|
264 | self.exit_now = threading.Event() | |
|
266 | 265 | |
|
267 | 266 | def run(self): |
|
268 |
while |
|
|
269 | self.cond.acquire() | |
|
270 | self.cond.wait(self.time_interval) | |
|
271 | self.cond.release() | |
|
272 | if self.exit_now==True: | |
|
267 | while True: | |
|
268 | self.exit_now.wait(self.time_interval) | |
|
269 | if self.exit_now.is_set(): | |
|
273 | 270 | break |
|
274 | 271 | #printing for debug |
|
275 | 272 | #print("Saving...") |
|
276 | 273 | self.IPython_object.save_history() |
|
277 | 274 | |
|
278 | 275 | def stop(self): |
|
279 |
self.exit_now |
|
|
280 |
self. |
|
|
281 | self.cond.notify() | |
|
282 | self.cond.release() | |
|
276 | self.exit_now.set() | |
|
277 | self.join() | |
|
283 | 278 | |
|
284 | 279 | def magic_history(self, parameter_s = ''): |
|
285 | 280 | """Print input history (_i<n> variables), with most recent last. |
@@ -294,7 +294,7 b' class InteractiveShell(Configurable, Magic):' | |||
|
294 | 294 | self.init_payload() |
|
295 | 295 | self.hooks.late_startup_hook() |
|
296 | 296 | atexit.register(self.atexit_operations) |
|
297 |
self.history_thread = HistorySaveThread(self, 60 |
|
|
297 | self.history_thread = HistorySaveThread(self, 60) | |
|
298 | 298 | self.history_thread.start() |
|
299 | 299 | |
|
300 | 300 | # While we're trying to have each part of the code directly access what it |
@@ -2526,6 +2526,7 b' class InteractiveShell(Configurable, Magic):' | |||
|
2526 | 2526 | except OSError: |
|
2527 | 2527 | pass |
|
2528 | 2528 | |
|
2529 | self.history_thread.stop() | |
|
2529 | 2530 | self.save_history() |
|
2530 | 2531 | |
|
2531 | 2532 | # Clear all user namespaces to release all references cleanly. |
General Comments 0
You need to be logged in to leave comments.
Login now