From 27c43ce5908e6cd1ccefd81e11ae60eda226f560 Mon Sep 17 00:00:00 2001 From: Andrea Rizzi Date: Thu, 30 May 2019 12:41:54 +0200 Subject: [PATCH] Attempt setting env var HDF5_USE_FILE_LOCKING to false when opening netcdf file on failure --- openmmtools/multistate/multistatereporter.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openmmtools/multistate/multistatereporter.py b/openmmtools/multistate/multistatereporter.py index d6109dcce..b1ee7d4af 100644 --- a/openmmtools/multistate/multistatereporter.py +++ b/openmmtools/multistate/multistatereporter.py @@ -375,6 +375,10 @@ def _open_dataset_robustly(self, *args, n_attempts=5, sleep_time=2, 'in {} seconds'.format(attempt+1, n_attempts, sleep_time)) time.sleep(sleep_time) + # At the very last attempt, we try setting the environment variable + # controlling the locking mechanism of HDF5 (see choderalab/yank#1165). + if n_attempts > 1: + os.environ['HDF5_USE_FILE_LOCKING'] = 'FALSE' # Last attempt finally raises any error. return netcdf.Dataset(*args, **kwargs)