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
|
self.progressCallback = progressCallback
|
||||||
|
|
||||||
# Open the file
|
try:
|
||||||
self.f = h5py.File(self.fn, "w")
|
# 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
|
# This flag is used to delete the file on finish(), and can be used
|
||||||
# when a recording is canceled.
|
# when a recording is canceled.
|
||||||
@ -174,6 +178,7 @@ class Recording:
|
|||||||
),
|
),
|
||||||
compression="gzip",
|
compression="gzip",
|
||||||
)
|
)
|
||||||
|
self.f.flush()
|
||||||
|
|
||||||
def inCallback(self, adata):
|
def inCallback(self, adata):
|
||||||
"""
|
"""
|
||||||
@ -184,6 +189,7 @@ class Recording:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
if self.stop():
|
if self.stop():
|
||||||
|
logging.debug('Stop flag set, early return in inCallback')
|
||||||
# Stop flag is raised. We do not add any data anymore.
|
# Stop flag is raised. We do not add any data anymore.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -201,7 +207,8 @@ class Recording:
|
|||||||
the recording. Typically used for cleaning up after canceling a
|
the recording. Typically used for cleaning up after canceling a
|
||||||
recording.
|
recording.
|
||||||
"""
|
"""
|
||||||
self.deleteFile = val
|
with self.file_mtx:
|
||||||
|
self.deleteFile = val
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
"""
|
"""
|
||||||
@ -214,18 +221,21 @@ class Recording:
|
|||||||
self.stop <<= True
|
self.stop <<= True
|
||||||
|
|
||||||
with self.file_mtx:
|
with self.file_mtx:
|
||||||
|
self.f.flush()
|
||||||
# Remove indata handler, which also should remove callback function
|
# Remove indata handler, which also should remove callback function
|
||||||
# from StreamMgr.
|
# from StreamMgr. This, however does not have to happen
|
||||||
self.indh = None
|
# 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
|
# Remove handle to dataset otherwise the h5 file is not closed
|
||||||
# properly.
|
# properly.
|
||||||
self.ad = None
|
del self.ad
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Close the recording file
|
# Close the recording file
|
||||||
self.f.close()
|
self.f.close()
|
||||||
|
del self.f
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error closing file: {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
|
# Add the data to the file, and resize the audio data blocks
|
||||||
self.ad.resize(ablockno, axis=0)
|
self.ad.resize(ablockno, axis=0)
|
||||||
self.ad[ablockno - 1, :, :] = indata
|
self.ad[ablockno - 1, :, :] = indata
|
||||||
|
self.f.flush()
|
||||||
|
Loading…
Reference in New Issue
Block a user