diff --git a/cal_tools/cal_tools/tools.py b/cal_tools/cal_tools/tools.py index 2943381d897d1bc437bfb0720021a994caf5a801..435c998cae18918f13fd0038450d56fa171df7a6 100644 --- a/cal_tools/cal_tools/tools.py +++ b/cal_tools/cal_tools/tools.py @@ -237,7 +237,7 @@ already_printed = {} def get_from_db(device, constant, condition, empty_constant, cal_db_interface, creation_time=None, - verbosity=1, timeout=30000, ntries=120, meta_only=True, + verbosity=1, timeout=30000, ntries=7, meta_only=True, version_info=False): """ Return calibration constants and metadata requested from CalDB @@ -250,6 +250,8 @@ def get_from_db(device, constant, condition, empty_constant, :param creation_time: Latest time for constant to be created :param verbosity: Level of verbosity (0 - silent) :param timeout: Timeout for zmq request + ntries is set to 7 so that if the timeout started at 30s last timeout + will be ~ 1h. :param ntries: number of tries to contact the database :param meta_only: Retrieve only metadata via ZMQ. Constants are taken directly from the h5 file on maxwell. @@ -288,6 +290,7 @@ def get_from_db(device, constant, condition, empty_constant, break except zmq.error.Again: ntries -= 1 + timeout *= 2 sleep(np.random.randint(30)) except Exception as e: if verbosity > 0: @@ -314,7 +317,7 @@ def get_from_db(device, constant, condition, empty_constant, def send_to_db(device, constant, condition, file_loc, cal_db_interface, creation_time=None, - verbosity=1, timeout=30000, ntries=120, doraise=False): + verbosity=1, timeout=30000, ntries=7, doraise=False): """ Return calibration constants and metadata requested from CalDB @@ -326,7 +329,9 @@ def send_to_db(device, constant, condition, file_loc, :param creation_time: Latest time for constant to be created :param verbosity: Level of verbosity (0 - silent) :param timeout: Timeout for zmq request - :param ntries: number of tries to contact the database + :param ntries: number of tries to contact the database, + ntries is set to 7 so that if the timeout started at 30s last timeout + will be ~ 1h. :param doraise: if True raise errors during communication with DB """ from iCalibrationDB import ConstantMetaData, Versions @@ -354,6 +359,7 @@ def send_to_db(device, constant, condition, file_loc, break except zmq.error.Again: ntries -= 1 + timeout *= 2 sleep(np.random.randint(30)) if ntries == 0 and doraise: raise