diff --git a/src/calibre/utils/test_lock.py b/src/calibre/utils/test_lock.py index b9d2d9371d..cc8eff6620 100644 --- a/src/calibre/utils/test_lock.py +++ b/src/calibre/utils/test_lock.py @@ -62,7 +62,12 @@ class IPCLockTest(unittest.TestCase): def tearDown(self): os.chdir(self.cwd) - shutil.rmtree(self.tdir) + for i in range(100): + try: + shutil.rmtree(self.tdir) + break + except EnvironmentError: + time.sleep(0.1) def test_exclusive_file_same_process(self): fname = 'testsp'