From 5f426e693903c5be7d8e03bb08dca5f71c083055 Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@stfc.ac.uk>
Date: Mon, 30 Jul 2018 10:28:17 +0100
Subject: [PATCH] Only sleep after doctests if free memory is below 50%

---
 docs/source/conf.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/docs/source/conf.py b/docs/source/conf.py
index be1eb1ab003..062cdc8a281 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -8,7 +8,7 @@ import os
 from sphinx import __version__ as sphinx_version
 import sphinx_bootstrap_theme # checked at cmake time
 import mantid
-from mantid import ConfigService
+from mantid.kernel import ConfigService
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -106,9 +106,13 @@ except TypeError:
 doctest_global_cleanup = """
 import time
 from mantid.api import FrameworkManager
+from mantid.kernel import MemoryStats
+
 FrameworkManager.Instance().clear()
-# sleep for short period to allow memory to be freed
-time.sleep(2)
+if MemoryStats().getFreeRatio() < 0.5:
+    # sleep for short period to allow memory to be freed
+    time.sleep(2)
+
 """
 
 # -- Options for pngmath --------------------------------------------------
-- 
GitLab