Added extra flush statements for hdf5 file. This helps for Thijs' machine
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
8711c6c57d
commit
839ca4f77c
@ -82,8 +82,12 @@ class Recording:
|
||||
|
||||
self.progressCallback = progressCallback
|
||||
|
||||
# Open the file
|
||||
self.f = h5py.File(self.fn, "w")
|
||||
try:
|
||||
# Open the file
|
||||
self.f = h5py.File(self.fn, "w", 'stdio')
|
||||
except Exception as e:
|
||||
logging.error(f'Error creating measurement file {e}')
|
||||
raise
|
||||
|
||||
# This flag is used to delete the file on finish(), and can be used
|
||||
# when a recording is canceled.
|
||||
@ -174,6 +178,7 @@ class Recording:
|
||||
),
|
||||
compression="gzip",
|
||||
)
|
||||
self.f.flush()
|
||||
|
||||
def inCallback(self, adata):
|
||||
"""
|
||||
@ -184,6 +189,7 @@ class Recording:
|
||||
|
||||
"""
|
||||
if self.stop():
|
||||
logging.debug('Stop flag set, early return in inCallback')
|
||||
# Stop flag is raised. We do not add any data anymore.
|
||||
return True
|
||||
|
||||
@ -201,7 +207,8 @@ class Recording:
|
||||
the recording. Typically used for cleaning up after canceling a
|
||||
recording.
|
||||
"""
|
||||
self.deleteFile = val
|
||||
with self.file_mtx:
|
||||
self.deleteFile = val
|
||||
|
||||
def finish(self):
|
||||
"""
|
||||
@ -214,18 +221,21 @@ class Recording:
|
||||
self.stop <<= True
|
||||
|
||||
with self.file_mtx:
|
||||
|
||||
self.f.flush()
|
||||
# Remove indata handler, which also should remove callback function
|
||||
# from StreamMgr.
|
||||
self.indh = None
|
||||
|
||||
# from StreamMgr. This, however does not have to happen
|
||||
# instantaneously. For which we have to implement extra mutex
|
||||
# guards in this class
|
||||
del self.indh
|
||||
|
||||
# Remove handle to dataset otherwise the h5 file is not closed
|
||||
# properly.
|
||||
self.ad = None
|
||||
del self.ad
|
||||
|
||||
try:
|
||||
# Close the recording file
|
||||
self.f.close()
|
||||
del self.f
|
||||
except Exception as e:
|
||||
logging.error(f"Error closing file: {e}")
|
||||
|
||||
@ -288,3 +298,4 @@ class Recording:
|
||||
# Add the data to the file, and resize the audio data blocks
|
||||
self.ad.resize(ablockno, axis=0)
|
||||
self.ad[ablockno - 1, :, :] = indata
|
||||
self.f.flush()
|
||||
|
Loading…
Reference in New Issue
Block a user