From 7e82c626c44a6924af38d0a8af3cc8b2d13873ec Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 9 Dec 2023 15:13:40 +0200 Subject: [PATCH] [3.12] gh-79429: Ignore FileNotFoundError when remove a temporary directory in the multiprocessing finalizer (GH-112865) --- Lib/multiprocessing/util.py | 5 ++++- .../Library/2023-12-08-11-52-08.gh-issue-79429.Nf9VK2.rst | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2023-12-08-11-52-08.gh-issue-79429.Nf9VK2.rst diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py index 6ee0d33e88a060..8ff82bf86ff962 100644 --- a/Lib/multiprocessing/util.py +++ b/Lib/multiprocessing/util.py @@ -130,7 +130,10 @@ def is_abstract_socket_namespace(address): # def _remove_temp_dir(rmtree, tempdir): - rmtree(tempdir) + def onerror(func, path, err_info): + if not issubclass(err_info[0], FileNotFoundError): + raise + rmtree(tempdir, onerror=onerror) current_process = process.current_process() # current_process() can be None if the finalizer is called diff --git a/Misc/NEWS.d/next/Library/2023-12-08-11-52-08.gh-issue-79429.Nf9VK2.rst b/Misc/NEWS.d/next/Library/2023-12-08-11-52-08.gh-issue-79429.Nf9VK2.rst new file mode 100644 index 00000000000000..8363ab54c966cc --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-12-08-11-52-08.gh-issue-79429.Nf9VK2.rst @@ -0,0 +1,2 @@ +Ignore FileNotFoundError when remove a temporary directory in the +multiprocessing finalizer.