Open
Description
Hi !
I recently have had an error when opening the binary file :
sys:1: ResourceWarning: unclosed file <_io.BufferedReader name='my\\dat\\file.dat'>
I used tramalloc
to identify where the file was being opened and it is here:
class BinaryRecordingSegment(BaseRecordingSegment):
def __init__(self, file_path, sampling_frequency, t_start, num_channels, dtype, time_axis, file_offset):
BaseRecordingSegment.__init__(self, sampling_frequency=sampling_frequency, t_start=t_start)
self.num_channels = num_channels
self.dtype = np.dtype(dtype)
self.file_offset = file_offset
self.time_axis = time_axis
self.file_path = file_path
self.file = open(self.file_path, "rb")
self.bytes_per_sample = self.num_channels * self.dtype.itemsize
self.data_size_in_bytes = Path(file_path).stat().st_size - file_offset
self.num_samples = self.data_size_in_bytes // self.bytes_per_sample
It is opening the file self.file = open(self.file_path, "rb")
, but never close it, could it be an issue? I never had this error before so I don't know what led to it. Am I missing something?