From 46137ca7d0033cb4f5cd0d5e38947fe59bb49ab3 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 13 May 2019 16:57:42 +0300 Subject: devtools: Try to delete temp Chrome data dir – hard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #17. --- crocoite/devtools.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crocoite') diff --git a/crocoite/devtools.py b/crocoite/devtools.py index fd56896..ea46aaa 100644 --- a/crocoite/devtools.py +++ b/crocoite/devtools.py @@ -323,7 +323,17 @@ class Process: async def __aexit__ (self, *exc): self.p.terminate () await self.p.wait () - shutil.rmtree (self.userDataDir) + + # Try to delete the temporary directory multiple times. It looks like + # Chrome will change files in there even after it exited (i.e. .wait() + # returned). Very strange. + for i in range (5): + try: + shutil.rmtree (self.userDataDir) + break + except: + await asyncio.sleep (0.2) + self.p = None return False -- cgit v1.2.3