diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2019-05-13 16:57:42 +0300 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2019-05-13 16:57:42 +0300 |
commit | 46137ca7d0033cb4f5cd0d5e38947fe59bb49ab3 (patch) | |
tree | 9fe4e0f342de9385a517794594f74dde04d21644 /crocoite | |
parent | ba5dbfd061d328a2140f0a7541ef0fdb6acf5903 (diff) | |
download | crocoite-46137ca7d0033cb4f5cd0d5e38947fe59bb49ab3.tar.gz crocoite-46137ca7d0033cb4f5cd0d5e38947fe59bb49ab3.tar.bz2 crocoite-46137ca7d0033cb4f5cd0d5e38947fe59bb49ab3.zip |
devtools: Try to delete temp Chrome data dir – hard
Fixes #17.
Diffstat (limited to 'crocoite')
-rw-r--r-- | crocoite/devtools.py | 12 |
1 files changed, 11 insertions, 1 deletions
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 |