From c64ca27fb334d40f245cb13b4158e1e1af1ba26f Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 8 Apr 2015 14:04:38 -0700 Subject: [PATCH] Add note about thread safety of fake filesystem Change-Id: Ic9851455b559a94bb011c27ba55ad050e6bd6d55 --- taskflow/persistence/backends/impl_memory.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/taskflow/persistence/backends/impl_memory.py b/taskflow/persistence/backends/impl_memory.py index 4cb90f00..e4d135fa 100644 --- a/taskflow/persistence/backends/impl_memory.py +++ b/taskflow/persistence/backends/impl_memory.py @@ -37,6 +37,15 @@ class FakeFilesystem(object): which are not relevant in an implementation of a in-memory fake filesystem). + **Not** thread-safe when a single filesystem is mutated at the same + time by multiple threads. For example having multiple threads call into + :meth:`~taskflow.persistence.backends.impl_memory.FakeFilesystem.clear` + at the same time could potentially end badly. It is thread-safe when only + :meth:`~taskflow.persistence.backends.impl_memory.FakeFilesystem.get` + or other read-only actions (like calling into + :meth:`~taskflow.persistence.backends.impl_memory.FakeFilesystem.ls`) + are occuring at the same time. + Example usage: >>> from taskflow.persistence.backends import impl_memory @@ -142,6 +151,7 @@ class FakeFilesystem(object): return paths def clear(self): + """Remove all nodes (except the root) from this filesystem.""" for node in list(self._root.reverse_iter()): node.disassociate()