Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Bliss
bliss
Commits
32169d14
Commit
32169d14
authored
Jul 22, 2021
by
Wout De Nolf
Browse files
more refined way to identify an HDF5 locked exception
parent
9c76a542
Pipeline
#51121
passed with stages
in 118 minutes and 28 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nexus_writer_service/io/nexus.py
View file @
32169d14
...
...
@@ -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
(
e
x
,
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
(
e
x
):
"""
:param
OSError
e:
:param
BaseException
e
x
:
: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
is
NoAccess
Error
(
e
):
def
is
Locked
Error
(
e
x
):
"""
:param
OSError
e:
:returns bool
:param
BaseException
e
x
:
: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
):
...
...
nexus_writer_service/utils/exceptions.py
0 → 100644
View file @
32169d14
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__
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment