Skip to content
Snippets Groups Projects

double timeout each try

Merged Karim Ahmed requested to merge feat/double_timeout_caltools into master
2 unresolved threads
1 file
+ 9
3
Compare changes
  • Side-by-side
  • Inline
@@ -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,
Please register or sign in to reply
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:
Please register or sign in to reply
raise
Loading