Skip to content

Commit 5f3da94

Browse files
authored
🐼Fix the 'too many files open' bug 🐛
Pillow apparently does not properly close image files on my laptop (even after upgrading to the newest version). This workaround fixed it for me.
1 parent 03e4b3a commit 5f3da94

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

python/pandaset/sensors.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,12 @@ def _load_intrinsics_structure(self) -> None:
313313
self._intrinsics_structure = intrinsics_file
314314

315315
def _load_data_file(self, fp: str) -> JpegImageFile:
316-
return Image.open(fp)
317-
316+
# solve this bug: https://github.com/python-pillow/Pillow/issues/1237
317+
img = Image.open(fp)
318+
image = img.copy()
319+
img.close()
320+
return image
321+
318322
def _load_intrinsics(self) -> None:
319323
with open(self._intrinsics_structure, 'r') as f:
320324
file_data = json.load(f)

0 commit comments

Comments
 (0)