classification
Title: shutil.make_archive should not need to chdir (alternatively: make shutil.make_archive thread-safe)
Type: Stage: patch review
Components: Library (Lib) Versions: Python 3.7, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Alex Gaynor, FFY00, Joey Harrington, andrei.avk, lukasz.langa, michael-o, miss-islington, serhiy.storchaka, tarek
Priority: normal Keywords: patch

Created on 2017-05-30 13:46 by Alex Gaynor, last changed 2021-09-17 13:26 by FFY00.

Pull Requests
URL Status Linked Edit
PR 26933 merged andrei.avk, 2021-06-28 13:13
PR 27274 merged miss-islington, 2021-07-21 08:33
PR 27275 merged miss-islington, 2021-07-21 08:33
PR 27276 merged miss-islington, 2021-07-21 08:33
PR 28271 FFY00, 2021-09-17 13:26
Messages (10)
msg294756 - (view) Author: Alex Gaynor (Alex Gaynor) Date: 2017-05-30 13:46
Currently shutil.make_archive uses os.chdir, however there's no need for that. Everything that's done could be equally accomplished with path manipulation:

https://github.com/python/cpython/blob/master/Lib/shutil.py#L773-L779

We should switch to using path manipulation in order to make shutil.make_archive thread safe.

(Flag: This is probably a good bug for someone with Python skills interested in contributing to CPython!)
msg294758 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-30 14:13
Unfortunately this is not possible. The signature of functions registered with register_archive_format() doesn't support this.
msg294759 - (view) Author: Alex Gaynor (Alex Gaynor) Date: 2017-05-30 14:13
None of those functions are a public API, so changing them shouldn't be a problem IMO.
msg294760 - (view) Author: Alex Gaynor (Alex Gaynor) Date: 2017-05-30 14:14
Ugh, except via |register_archive_format|. |register_archive_format| could wrap callables passed to it to maintain the current behavior.
msg297902 - (view) Author: Joey Harrington (Joey Harrington) Date: 2017-07-07 18:55
It would be nice if there was at least a warning in the docs that make_archive is not thread-safe, and that if you have two threads creating archives that it's extremely likely you'll get erroneous results since the race condition lasts for the entire duration of the archive creation.
msg389849 - (view) Author: Michael Osipov (michael-o) * Date: 2021-03-30 20:09
Just wasted two hours for this. Can someone really update the documentation of it if this is not going to change.
msg396633 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-06-28 13:14
PR is added here:
https://github.com/python/cpython/pull/26933
msg397928 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-21 08:33
New changeset 64f54b7ccd49764b0304e076bfd79b5482988f53 by andrei kulakov in branch 'main':
bpo-30511: Add note on thread safety to shutil.make_archive() (#26933)
https://github.com/python/cpython/commit/64f54b7ccd49764b0304e076bfd79b5482988f53
msg397932 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-21 08:55
New changeset d17449f31d4af7a735e81b587bb329481764412f by Miss Islington (bot) in branch '3.10':
bpo-30511: Add note on thread safety to shutil.make_archive() (GH-26933) (GH-27274)
https://github.com/python/cpython/commit/d17449f31d4af7a735e81b587bb329481764412f
msg397934 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-21 09:04
New changeset c8e35abfe304eb052a5220974006072c37d4b06a by Miss Islington (bot) in branch '3.9':
bpo-30511: Add note on thread safety to shutil.make_archive() (GH-26933) (GH-27275)
https://github.com/python/cpython/commit/c8e35abfe304eb052a5220974006072c37d4b06a
msg397935 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-21 09:04
New changeset 54d387105a5f0c3825a0f4fa607b58d55d05e572 by Miss Islington (bot) in branch '3.8':
bpo-30511: Add note on thread safety to shutil.make_archive() (GH-26933) (#27276)
https://github.com/python/cpython/commit/54d387105a5f0c3825a0f4fa607b58d55d05e572
History
Date User Action Args
2021-09-17 13:26:13FFY00setnosy: + FFY00
pull_requests: + pull_request26830
2021-07-21 09:04:56lukasz.langasetmessages: + msg397935
2021-07-21 09:04:55lukasz.langasetmessages: + msg397934
2021-07-21 08:55:47lukasz.langasetmessages: + msg397932
2021-07-21 08:33:47miss-islingtonsetpull_requests: + pull_request25821
2021-07-21 08:33:41miss-islingtonsetpull_requests: + pull_request25820
2021-07-21 08:33:36miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25819
2021-07-21 08:33:15lukasz.langasetnosy: + lukasz.langa
messages: + msg397928
2021-06-28 13:14:35andrei.avksetmessages: + msg396633
2021-06-28 13:13:36andrei.avksetkeywords: + patch
nosy: + andrei.avk

pull_requests: + pull_request25502
stage: patch review
2021-03-30 20:09:12michael-osetnosy: + michael-o
messages: + msg389849
2017-07-07 18:55:53Joey Harringtonsetnosy: + Joey Harrington
messages: + msg297902
2017-05-30 14:14:46Alex Gaynorsetmessages: + msg294760
2017-05-30 14:13:47Alex Gaynorsetmessages: + msg294759
2017-05-30 14:13:05serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg294758
2017-05-30 13:46:18Alex Gaynorcreate