Can't get exclusive file lock when safely renaming a file

Steve M sjmaster at gmail.com
Sat Dec 6 17:59:26 CET 2008


On Dec 6, 12:25 am, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:

> The rename works, but here is my problem: after getting what I thought
> was an exclusive lock on the new file, but before calling os.rename(), I
> can still over-write it from another process:
>
> $ echo "this comes from another process" > spam.txt
> $ cat spam.txt
> this comes from another process

What happens if you try to delete spam.txt at this point instead of
over-write it?



More information about the Python-list mailing list