summaryrefslogtreecommitdiff
path: root/giscanner/dumper.py
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-06-20 08:08:03 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-06-20 08:08:03 +0200
commit7c6adf533001e214e63d284a1a00fa254b29d7b9 (patch)
tree879c619e4e6b366dc7d523d35c3690e23b58680c /giscanner/dumper.py
parentd3a9346d5056c8da4d5261ed47bc5d52ace84aa8 (diff)
downloadgobject-introspection-7c6adf533001e214e63d284a1a00fa254b29d7b9.tar.gz
Add utils.rmtree() which waits and tries again if a file is still in use
On Windows the dumper cleanup regularely fails because the created .exe is still in use by some process and shutil.rmtree() fails with: OSError: [WinError 145] The directory is not empty I'm not 100% sure what's the cause for this, but searching for similar issues suggests that it might be Windows Defender scanning the newly created .exe file and because it's so short lifed the scanning and deleting conflict. This adds a helper which tries a few times and waits a bit before giving up. A similar patch has been in MSYS2 for some time: https://github.com/Alexpux/MINGW-packages/blob/d0c39af02a669e45272c713e912ee63b0dd94157/mingw-w64-gobject-introspection/0025-more-tolerant-rmtreeing.patch
Diffstat (limited to 'giscanner/dumper.py')
-rw-r--r--giscanner/dumper.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/giscanner/dumper.py b/giscanner/dumper.py
index 06737188..d6956da2 100644
--- a/giscanner/dumper.py
+++ b/giscanner/dumper.py
@@ -28,7 +28,6 @@ import os
import sys
import shlex
import subprocess
-import shutil
import tempfile
from distutils.errors import LinkError
@@ -171,14 +170,14 @@ class DumpCompiler(object):
introspection_obj = self._compile(c_path)
except CompilerError as e:
if not utils.have_debug_flag('save-temps'):
- shutil.rmtree(tmpdir)
+ utils.rmtree(tmpdir)
raise SystemExit('compilation of temporary binary failed:' + str(e))
try:
self._link(bin_path, introspection_obj)
except LinkerError as e:
if not utils.have_debug_flag('save-temps'):
- shutil.rmtree(tmpdir)
+ utils.rmtree(tmpdir)
raise SystemExit('linking of temporary binary failed: ' + str(e))
return IntrospectionBinary([bin_path], tmpdir)