diff --git a/notebook/services/contents/fileio.py b/notebook/services/contents/fileio.py index b9d38726a..003491194 100644 --- a/notebook/services/contents/fileio.py +++ b/notebook/services/contents/fileio.py @@ -171,8 +171,10 @@ class FileManagerMixin(Configurable): log : logging.Logger """ - use_atomic_writing = Bool(True, config=True, help="""flag to deactivate - atomic writing on slow (like networked) file system.""") + use_atomic_writing = Bool(True, config=True, help= + """By default notebooks are saved on disk on a temporary file and then if succefully written, it replaces the old ones. + This procedure, namely 'atomic_writing', causes some bugs on file system whitout operation order enforcement (like some networked fs). + If set to False, the new notebook is written directly on the old one which could fail (eg: full filesystem or quota )""") @contextmanager def open(self, os_path, *args, **kwargs): @@ -183,7 +185,9 @@ class FileManagerMixin(Configurable): @contextmanager def atomic_writing(self, os_path, *args, **kwargs): - """wrapper around atomic_writing that turns permission errors to 403""" + """wrapper around atomic_writing that turns permission errors to 403. + Depending on flag 'use_atomic_writing', the wrapper perform an actual atomic writing or + simply writes the file (whatever an old exists or not)""" with self.perm_to_403(os_path): if self.use_atomic_writing: with atomic_writing(os_path, *args, log=self.log, **kwargs) as f: diff --git a/notebook/services/contents/tests/test_manager.py b/notebook/services/contents/tests/test_manager.py index 7b224e4f5..7954f6726 100644 --- a/notebook/services/contents/tests/test_manager.py +++ b/notebook/services/contents/tests/test_manager.py @@ -530,7 +530,10 @@ class TestContentsManager(TestCase): assert cm.notary.check_signature(nb) -class TestContentsManagerNoAtomic(TestCase): +class TestContentsManagerNoAtomic(TestContentsManager): + """ + Make same test in no atomic case than in atomic case, using inheritance + """ def setUp(self): self._temp_dir = TemporaryDirectory() @@ -539,23 +542,3 @@ class TestContentsManagerNoAtomic(TestCase): root_dir = self.td, ) self.contents_manager.use_atomic_writing = False - - def tearDown(self): - self._temp_dir.cleanup() - - def new_notebook_no_atomic(self): - """ - - """ - cm = self.contents_manager - model = cm.new_untitled(type="notebook") - name = model['name'] - path = model['path'] - - full_model = cm.get(path) - nb = full_model['content'] - nb['metadata']['counter'] = int(1e6 * time.time()) - self.add_code_cell(nb) - - cm.save(full_model, path) - return nb, name, path