diff --git a/sotodlib/toast/ops/utils.py b/sotodlib/toast/ops/utils.py index b0087c029..f0b1c3179 100644 --- a/sotodlib/toast/ops/utils.py +++ b/sotodlib/toast/ops/utils.py @@ -2,6 +2,7 @@ # Full license can be found in the top level "LICENSE" file. import os +import time import pickle from astropy import constants @@ -89,13 +90,13 @@ def persistent_pickle_load(fname, n_try_max=6, wait_time=10): try: with open(fname, "rb") as f: payload = pickle.load(f) - except EOFError: + except (EOFError, pickle.UnpicklingError): if n_try == n_try_max - 1: log.warning(f"EOF at {fname}, nothing loaded") return None else: log.warning(f"EOF at {fname}, waiting for {wait_time} seconds") - sleep(wait_time) + time.sleep(wait_time) continue break # success