04.06.19 10:25, Inada Naoki пише:
On Sat, Jun 1, 2019 at 4:10 PM Serhiy Storchaka <storch...@gmail.com> wrote:
Why do you need to replace a symlink atomically? This is a solution,
what problem it solves?
There is another, more common / realistic usage of atomic symlink
replacing.
When deploy PHP application or static web contents to web servers,
symlink is used for "atomic deployment". Roughly speaking, it is like this:
```
rsync -avK v2/ web:contents/v2/
ssh web "cd contents && ln -sf v2 current" # current/ is exposed by web server
```
If "ln -sf" is not atomic and do remove & symlink, web server or php
will return 404 error between remove and symlink.
I feel this use case is more real world application than
"I don't want exception even when other process creates file
at the same time".
Thank you, Inada-san, your example convinced me. Now I agree that it is
worth to add shutil.symlink (and maybe shutil.link) which supports the
"ln -sf" behavior.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/MCNF64E2ORUXSYX3CPXK5R57TXFLKNOA/
Code of Conduct: http://python.org/psf/codeofconduct/