From 667a4863541b2446a30b35ec0f5a64bee1370361 Mon Sep 17 00:00:00 2001
From: Matthew Pitkin <matthew.pitkin@ligo.org>
Date: Thu, 29 Feb 2024 15:02:19 +0000
Subject: [PATCH] Update dynesty.py: catch error if trying to load zero bytes
 resume file

---
 bilby/core/sampler/dynesty.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bilby/core/sampler/dynesty.py b/bilby/core/sampler/dynesty.py
index 852fb88c1..bb931ed3b 100644
--- a/bilby/core/sampler/dynesty.py
+++ b/bilby/core/sampler/dynesty.py
@@ -736,7 +736,10 @@ class Dynesty(NestedSampler):
         if os.path.isfile(self.resume_file):
             logger.info(f"Reading resume file {self.resume_file}")
             with open(self.resume_file, "rb") as file:
-                sampler = dill.load(file)
+                try:
+                    sampler = dill.load(file)
+                except EOFError:
+                    sampler = None
 
                 if not hasattr(sampler, "versions"):
                     logger.warning(
-- 
GitLab