Skip to content

Commit

Permalink
fix: permission error (KwaiVGI#273)
Browse files Browse the repository at this point in the history
* Close temporary file handle

Close temporary file handle

* Close temporary file handle before copy

Close temporary file handle before copy
  • Loading branch information
v3ucn authored Aug 5, 2024
1 parent 4cb864f commit 67d567f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/dependencies/XPose/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def _file2dict(filename):
temp_config_file = tempfile.NamedTemporaryFile(
dir=temp_config_dir, suffix='.py')
temp_config_name = osp.basename(temp_config_file.name)
# close temp file before copy
temp_config_file.close()
shutil.copyfile(filename,
osp.join(temp_config_dir, temp_config_name))
temp_module_name = osp.splitext(temp_config_name)[0]
Expand All @@ -95,8 +97,8 @@ def _file2dict(filename):
}
# delete imported module
del sys.modules[temp_module_name]
# close temp file
temp_config_file.close()


elif filename.lower().endswith(('.yml', '.yaml', '.json')):
from .slio import slload
cfg_dict = slload(filename)
Expand Down

0 comments on commit 67d567f

Please sign in to comment.