From 5f081fc0a770265d3a21662697f3cb5f7d50f4ca 2014-05-16 23:08:35 From: Thomas Kluyver Date: 2014-05-16 23:08:35 Subject: [PATCH] Merge pull request #5874 from takluyver/test-hist-close-db Ensure history database is closed in test --- diff --git a/IPython/core/history.py b/IPython/core/history.py index da10813..c9b8435 100644 --- a/IPython/core/history.py +++ b/IPython/core/history.py @@ -775,6 +775,7 @@ class HistorySavingThread(threading.Thread): while True: self.history_manager.save_flag.wait() if self.stop_now: + self.db.close() return self.history_manager.save_flag.clear() self.history_manager.writeout_cache(self.db) diff --git a/IPython/core/tests/test_history.py b/IPython/core/tests/test_history.py index 1ec2852..c08156b 100644 --- a/IPython/core/tests/test_history.py +++ b/IPython/core/tests/test_history.py @@ -136,6 +136,8 @@ def test_history(): finally: # Ensure saving thread is shut down before we try to clean up the files ip.history_manager.save_thread.stop() + # Forcibly close database rather than relying on garbage collection + ip.history_manager.db.close() # Restore history manager ip.history_manager = hist_manager_ori