Rewriting file #690
Replies: 4 comments 2 replies
-
Or this approach is better?
|
Beta Was this translation helpful? Give feedback.
-
I think S3 supports some sort of object versioning, so you could read from one version and while writing to another version of the same object, but it feels a bit dodgy. I'd consider writing to a separate file, and then moving / renaming it when finished, atomically. It probably achieves the same thing more explicitly. |
Beta Was this translation helpful? Give feedback.
-
@Tonkonozhenko It may be safe:
... but all the above are implementation details, so I wouldn't count on it working. The other problem is that it may work for some URLs, like S3, but the moment you change that URL to e.g. a local file, your implementation is guaranteed to break. |
Beta Was this translation helpful? Give feedback.
-
I actually think it would work for local files, at least on Linux. The two nested |
Beta Was this translation helpful? Give feedback.
-
Hi,
Is it safe to rewrite one file using smart_open with the next code?
Beta Was this translation helpful? Give feedback.
All reactions