Catch "connetion refused" from the DB and try again
Some of the scripts (e.g. ztplot.py
) crash when trying to communicate with the DB and receive a connection refused:
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/site-packages/km3pipe/core.py", line 321, in _drain
new_blob = module(blob_to_send)
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/site-packages/km3pipe/core.py", line 581, in __call__
return self.process(*args, **kwargs)
File "scripts/ztplot.py", line 91, in process
self._update_calibration()
File "scripts/ztplot.py", line 82, in _update_calibration
self.t0set = self.sds.t0sets(detid=self.det_id).iloc[-1]['CALIBSETID']
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/site-packages/km3pipe/db.py", line 533, in func
return self.get(stream, **kwargs)
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/site-packages/km3pipe/db.py", line 599, in get
data = self._db._get_content(url)
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/site-packages/km3pipe/db.py", line 374, in _get_content
f = self.opener.open(target_url)
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/home/monitoring/.pyenv/versions/3.6.8/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>