Skip to content

Commit fc7705f

Browse files
authored
Merge pull request #28 from score-p/hotfix
ensure to clean up at startup
2 parents 8dba9d0 + 5691f11 commit fc7705f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/scorep_jupyter/userpersistence.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def __init__(self, serializer='dill', mode='memory'):
2121
{'os_environ': '', 'sys_path': '', 'var': ''},
2222
'subprocess':
2323
{'os_environ': '', 'sys_path': '', 'var': ''}}
24+
#ensure to start from scratch(e.g. dirs might not be deleted when changing serializer settings at runtime)
25+
self.postprocess(force_clean=True)
2426

2527
def preprocess(self):
2628
uid = str(uuid.uuid4())
@@ -54,17 +56,17 @@ def preprocess(self):
5456
return False
5557
return True
5658

57-
def postprocess(self):
59+
def postprocess(self, force_clean=False):
5860
"""
5961
Clean up files used for transmitting persistence and running subprocess.
6062
"""
61-
if self.mode == 'memory':
63+
if self.mode == 'memory' or force_clean:
6264
for key1 in self.paths:
6365
for key2 in self.paths[key1]:
6466
fd_path = self.paths[key1][key2]
6567
if os.path.exists(fd_path):
6668
os.unlink(fd_path)
67-
elif self.mode == 'disk':
69+
if self.mode == 'disk' or force_clean:
6870
if os.path.exists(str(self.base_path)):
6971
shutil.rmtree(str(self.base_path))
7072

0 commit comments

Comments
 (0)