Skip to content

Commit

Permalink
Merge pull request #19 from AutoActuary/openpyxl-atexit-ALL_TEMP_FILE…
Browse files Browse the repository at this point in the history
…S-clear

Make sure ALL_TEMP_FILES is cleared by our custom atexit function
  • Loading branch information
heetbeet authored Jun 7, 2024
2 parents b4a394e + 87639e7 commit daa8d63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aa_py_openpyxl_util/_workarounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ def remove_atexit_permission_error() -> None:

@atexit.register
def _openpyxl_shutdown_fix() -> None:
for path in list(openpyxl.worksheet._writer.ALL_TEMP_FILES):
temp_files_copy = openpyxl.worksheet._writer.ALL_TEMP_FILES.copy()
openpyxl.worksheet._writer.ALL_TEMP_FILES.clear()

for path in temp_files_copy:
if os.path.exists(path):
try:
os.remove(path)
except PermissionError:
pass
openpyxl.worksheet._writer.ALL_TEMP_FILES.remove(path)

0 comments on commit daa8d63

Please sign in to comment.