From 85bf7c3794cf268f1a016420fbe36f85374151f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Mon, 2 Dec 2024 13:52:53 +0100 Subject: [PATCH 1/3] Indicate that `Shelve.sync()` is not thread-safe. --- Doc/library/shelve.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst index 6e74a59b82b8ec..f6c346f8e031ff 100644 --- a/Doc/library/shelve.rst +++ b/Doc/library/shelve.rst @@ -78,6 +78,13 @@ Two additional methods are supported: dictionary on disk, if feasible. This is called automatically when the shelf is closed with :meth:`close`. + .. warning:: + + During the call to :meth:`!sync`, the *writeback* attribute is set to + :const:`False` and other threads will stop updating the cache. As such, + this method is **not** thread-safe. + + .. method:: Shelf.close() Synchronize and close the persistent *dict* object. Operations on a closed From 4d9f843f158a2a8bb2061436206e2677c3f6480d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 24 Aug 2025 12:07:44 +0200 Subject: [PATCH 2/3] amend merge commit --- Doc/library/shelve.rst | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst index 8775dbaa1044c7..b9f11b8a1522ea 100644 --- a/Doc/library/shelve.rst +++ b/Doc/library/shelve.rst @@ -89,7 +89,7 @@ Shelf objects support most of methods and operations supported by dictionaries (except copying, constructors and operators ``|`` and ``|=``). This eases the transition from dictionary based scripts to those requiring persistent storage. -Two additional methods are supported: +The following additional methods are supported: .. method:: Shelf.sync() @@ -98,6 +98,12 @@ Two additional methods are supported: dictionary on disk, if feasible. This is called automatically when :meth:`reorganize` is called or the shelf is closed with :meth:`close`. + .. warning:: + + When calling :meth:`sync`, *writeback* attribute is temporarily set to + :const:`False` and other threads will stop updating the cache. As such, + this method, and any method calling it, is **not** thread-safe. + .. method:: Shelf.reorganize() Calls :meth:`sync` and attempts to shrink space used on disk by removing empty @@ -105,13 +111,6 @@ Two additional methods are supported: .. versionadded:: next - .. warning:: - - During the call to :meth:`!sync`, the *writeback* attribute is set to - :const:`False` and other threads will stop updating the cache. As such, - this method is **not** thread-safe. - - .. method:: Shelf.close() Synchronize and close the persistent *dict* object. Operations on a closed From a99d745f6706e36cf20be3c66f2fb49814995ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Sun, 24 Aug 2025 12:08:22 +0200 Subject: [PATCH 3/3] refine warning --- Doc/library/shelve.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst index b9f11b8a1522ea..3f89ed4b289613 100644 --- a/Doc/library/shelve.rst +++ b/Doc/library/shelve.rst @@ -100,8 +100,8 @@ The following additional methods are supported: .. warning:: - When calling :meth:`sync`, *writeback* attribute is temporarily set to - :const:`False` and other threads will stop updating the cache. As such, + When calling :meth:`sync`, the *writeback* attribute is temporarily set + to :const:`False` and other threads will stop updating the cache. Thus, this method, and any method calling it, is **not** thread-safe. .. method:: Shelf.reorganize()