Commit 6dad7eb8 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch '2874-hdf5-locking-errors-wrongly-identified' into 'master'

Resolve "HDF5 locking errors wrongly identified?"

Closes #2874

See merge request !3887
parents 279376c4 32169d14
Pipeline #51257 failed with stages
in 105 minutes and 32 seconds
......@@ -19,7 +19,6 @@ import numpy
import os
import errno
import re
import traceback
import pprint
import logging
import bliss
......@@ -34,6 +33,7 @@ from .io_utils import mkdir
from ..utils import data_merging
from ..utils.process_utils import file_processes
from ..utils.async_utils import SharedLockPool
from ..utils.exceptions import iter_chained_exception
from silx.io import h5py_utils
DEFAULT_PLOT_NAME = "plotselect"
......@@ -852,31 +852,32 @@ def nxNote(parent, name, data=None, type=None, date=None, raise_on_exists=False)
return h5group
def isErrno(e, errno):
def _isErrno(ex, errno):
"""
:param OSError e:
:param BaseException ex:
:param int errno:
:returns bool:
"""
# Because e.__cause__ is None for chained exceptions
s = "".join(traceback.format_exception(None, e, None))
return f"errno = {errno}" in s
return f"errno = {errno}" in str(ex)
def isLockedError(e):
def _isLockedError(ex):
"""
:param OSError e:
:param BaseException ex:
:returns bool:
"""
# errno.EAGAIN: could also mean SWMR mode is required
return isErrno(e, errno.EAGAIN)
return _isErrno(ex, errno.EAGAIN) and "unable to lock file" in str(ex)
def isNoAccessError(e):
def isLockedError(ex):
"""
:param OSError e:
:returns bool
:param BaseException ex:
:returns bool:
"""
return any(isErrno(e, _errno) for _errno in [errno.ENOENT, errno.EACCES])
for exi in iter_chained_exception(ex):
if _isLockedError(exi):
return True
return False
def lockedErrorMessage(filename):
......
def iter_chained_exception(error, include_top=True):
if include_top:
yield error
parent = error.__cause__ # explicitly chained
while parent is not None:
yield parent
parent = parent.__cause__
parent = error.__context__ # implicitly chained
while parent is not None:
yield parent
parent = parent.__context__
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment