Skip to content

Commit

Permalink
tmp files are being closed now
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Benes committed Jan 29, 2024
1 parent a124f82 commit 29e58b9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/jpeglib/spatial_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ def unquantized_coefficients(
pathlib.Path(dst.name).parent.mkdir(parents=True, exist_ok=True)
dst_uq = tempfile.NamedTemporaryFile('w', suffix='.bin', delete=False)
pathlib.Path(dst_uq.name).parent.mkdir(parents=True, exist_ok=True)
# dst.close()
# dst_uq.close()

self.write_spatial(
path=dst.name,
dct_method=dct_method,
Expand All @@ -243,6 +242,8 @@ def unquantized_coefficients(
print('opening', dst_uq.name)
with open(dst_uq.name, 'rb') as fp:
content = fp.read()
dst.close()
dst_uq.close()
os.remove(dst.name)
os.remove(dst_uq.name)
uq = struct.unpack(f'<{len(content)//4}f', content)
Expand Down

0 comments on commit 29e58b9

Please sign in to comment.