diff --git a/IPython/core/history.py b/IPython/core/history.py index 6c80f44..bff1631 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -261,14 +261,17 @@ class HistorySaveThread(threading.Thread): self.IPython_object = IPython_object self.time_interval = time_interval self.exit_now = exit_now + self.cond = threading.Condition() def run(self): while 1: + self.cond.acquire() + self.cond.wait(self.time_interval) + self.cond.release() if self.exit_now==True: break - time.sleep(self.time_interval) #printing for debug - #print("Saving...") + print("Saving...") self.IPython_object.save_history() def magic_history(self, parameter_s = ''): diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 05961bd..d1b2108 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -294,7 +294,7 @@ class InteractiveShell(Configurable, Magic): self.init_payload() self.hooks.late_startup_hook() atexit.register(self.atexit_operations) - self.history_thread = HistorySaveThread(self, 10, False) + self.history_thread = HistorySaveThread(self, 60, False) self.history_thread.start() # While we're trying to have each part of the code directly access what it diff --git a/IPython/frontend/terminal/interactiveshell.py b/IPython/frontend/terminal/interactiveshell.py index de170a2..207323d 100644 --- a/IPython/frontend/terminal/interactiveshell.py +++ b/IPython/frontend/terminal/interactiveshell.py @@ -500,9 +500,12 @@ class TerminalInteractiveShell(InteractiveShell): if self.confirm_exit: if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'): self.shell.history_thread.exit_now=True + self.shell.history_thread.cond.acquire() + self.shell.history_thread.cond.notify() + self.shell.history_thread.cond.release() self.ask_exit() else: - self.shell.history_thread = HistorySaveThread(self.shell, 10, False) + self.shell.history_thread = HistorySaveThread(self.shell, 60, False) self.shell.history_thread.start() self.ask_exit()