Skip to content

Commit af6c618

Browse files
committed
Update recording_tools.py
1 parent 559cbaa commit af6c618

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/spikeinterface/core/recording_tools.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,11 @@ def write_binary_recording(
132132
file_size_bytes = data_size_bytes + byte_offset
133133

134134
# Create an empty file with file_size_bytes
135-
file = open(file_path, "wb+")
135+
with open(file_path, "wb+") as file:
136+
# The previous implementation `file.truncate(file_size_bytes)` was slow on Windows (#3408)
137+
file.seek(file_size_bytes - 1)
138+
file.write(b"\0")
136139

137-
# The previous implementation `file.truncate(file_size_bytes)` was slow on Windows (#3408)
138-
file.seek(file_size_bytes - 1)
139-
file.write(b"\0")
140-
141-
file.close()
142140
assert Path(file_path).is_file()
143141

144142
# use executor (loop or workers)

0 commit comments

Comments
 (0)