[bitbake-devel] [PATCH] utils: Use rm -rf in remove()
Richard Purdie
richard.purdie at linuxfoundation.org
Thu Feb 7 23:55:02 UTC 2013
Whilst shutils.rmtree() is pythonic, its also slow. Its faster to
use rm -rf which makes optimal use of the right syscalls.
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 484fb2d..94ef447 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -533,13 +533,15 @@ def remove(path, recurse=False):
"""Equivalent to rm -f or rm -rf"""
if not path:
return
- import os, errno, shutil, glob
+ import os, errno, glob, subprocess
for name in glob.glob(path):
try:
os.unlink(name)
except OSError as exc:
if recurse and exc.errno == errno.EISDIR:
- shutil.rmtree(name)
+ # shutil.rmtree(name) would be ideal but its too slow
+ subprocess.call('rm -rf %s' % path, shell=True)
+ return
elif exc.errno != errno.ENOENT:
raise
More information about the bitbake-devel
mailing list