Skip to content

Commit

Permalink
Invoke gc.collect() when close() called
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Dec 7, 2021
1 parent 0c1052c commit 162995f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions py7zr/py7zr.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import datetime
import errno
import functools
import gc
import io
import os
import pathlib
Expand Down Expand Up @@ -783,10 +784,12 @@ def _is_solid(self):

def _var_release(self):
self._dict = None
self.files = None
self.header = None
self.worker = None
self.sig_header = None
self.worker.close()
del self.worker
del self.files
del self.header
del self.sig_header
gc.collect()

@staticmethod
def _make_file_info(target: pathlib.Path, arcname: Optional[str] = None, dereference=False) -> Dict[str, Any]:
Expand Down Expand Up @@ -1448,3 +1451,8 @@ def archive(self, fp: BinaryIO, files, folder, deref=False):
def register_filelike(self, id: int, fileish: Union[MemIO, pathlib.Path, None]) -> None:
"""register file-ish to worker."""
self.target_filepath[id] = fileish

def close(self):
del self.header
del self.files
del self.concurrent

0 comments on commit 162995f

Please sign in to comment.