Skip to content

Commit

Permalink
Merge pull request #58 from dschick/h5swmr
Browse files Browse the repository at this point in the history
Simultaneous write/read access to h5 files
  • Loading branch information
dschick authored Dec 27, 2023
2 parents 9241a45 + e3c8d03 commit 80bffe1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions pyEvalData/io/palxfel.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def parse_raw(self):
self.file_name.format(scan_number) + '.h5')

try:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
with h5py.File(h5_file, 'r') as h5:
header = h5['R{0:04d}/header'.format(scan_number)]

Expand Down Expand Up @@ -171,6 +172,7 @@ def read_raw_scan_data(self, scan):
self.file_name.format(scan.number),
self.file_name.format(scan.number) + '.h5')

os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
with h5py.File(h5_file, 'r') as h5:
entry = h5['R{0:04d}'.format(scan.number)]
# iterate through data fields
Expand Down
8 changes: 5 additions & 3 deletions pyEvalData/io/sardana_nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from numpy.core.records import fromarrays
import nexusformat.nexus as nxs
import os.path as path
import os

from .source import Source
from .scan import Scan
Expand Down Expand Up @@ -95,8 +95,9 @@ def parse_raw(self):
"""
self.log.info('parse_raw')
nxs_file_path = path.join(self.file_path, self.file_name)
nxs_file_path = os.path.join(self.file_path, self.file_name)
try:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
nxs_file = nxs.nxload(nxs_file_path, mode='r')
except nxs.NeXusError:
raise nxs.NeXusError('Sardana NeXus file \'{:s}\' does not exist!'.format(
Expand Down Expand Up @@ -144,8 +145,9 @@ def read_raw_scan_data(self, scan):
"""
self.log.info('read_raw_scan_data for scan #{:d}'.format(scan.number))
# try to open the file
nxs_file_path = path.join(self.file_path, self.file_name)
nxs_file_path = os.path.join(self.file_path, self.file_name)
try:
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
nxs_file = nxs.nxload(nxs_file_path, mode='r')
except nxs.NeXusError:
raise nxs.NeXusError('Sardana NeXus file \'{:s}\' does not exist!'.format(
Expand Down

0 comments on commit 80bffe1

Please sign in to comment.