osclib/util: provide rmtree_nfs_safe().

Still occurs and when in obs_operator context is even more annoying.
This commit is contained in:
Jimmy Berry 2019-09-18 21:10:49 -05:00
parent abb40adcd2
commit 81f8807cda

View File

@ -177,3 +177,17 @@ def sha1_short(data):
data = data.encode('utf-8')
return hashlib.sha1(data).hexdigest()[:7]
def rmtree_nfs_safe(path, attempts=5):
import shutil
try:
shutil.rmtree(path)
except OSError as e:
# Directory not empty due to slow filesystem (see #1326 old occurance).
if attempts <= 0 or e.errno != 39:
raise e
from time import sleep
sleep(0.25)
rmtree_nfs_safe(path, attempts - 1)