Hi Mike, On Mon, Jun 25, 2012 at 3:41 PM, Mike Graham <mikegraham@gmail.com> wrote:
I like the basic idea, but if we do something like this, it would be useful to have read access to the old version of the file while you are writing out the new version that might become permanent.
Thanks, though this sounds like another mechanism than the one I'm aiming for :-) I want to replace an existing file temporarily, and then restore it no matter what.
If I was to implement something like this, I'd use a "right a temporary file then copy it overwriting the old one when I'm done" approach rather than a "back up the file" approach so that if the process dies for a reason Python can't clean up after (like due to SIGKILL), the half-written file doesn't remain.
This is a very valid concern -- if the process dies unexpectedly I'd leave the file replaced and the original in some temporary directory. Not sure if there's a way around that, probably not.
I don't really like the name Backup but I can't think of a better name at the moment.
Me neither. Thanks, - Kim
Kim Gräsman wrote:
On Mon, Jun 25, 2012 at 3:41 PM, Mike Graham wrote:
I don't really like the name Backup but I can't think of a better name at the moment.
Me neither.
How about FileRollback, ModifyThenRestore, NowYouSeeItNowYouDont, or StupidThirdPartyProgramThatOnlyAllowsConfigThroughFiles ? Tongue-partly-in-cheek'ly yours, ~Ethan~
Am 25.06.2012 17:03, schrieb Kim Gräsman:
This is a very valid concern -- if the process dies unexpectedly I'd leave the file replaced and the original in some temporary directory. Not sure if there's a way around that, probably not.
Your algorithm doesn't take SIGKILL, SIGSEV or server crash into account. I don't see a chance to compensate for these problems. How about you fix the 3rd party code instead? -1 for addition of broken code. Sorry ;) Christian
On Mon, Jun 25, 2012 at 5:21 PM, Christian Heimes <lists@cheimes.de> wrote:
Am 25.06.2012 17:03, schrieb Kim Gräsman:
This is a very valid concern -- if the process dies unexpectedly I'd leave the file replaced and the original in some temporary directory. Not sure if there's a way around that, probably not.
Your algorithm doesn't take SIGKILL, SIGSEV or server crash into account. I don't see a chance to compensate for these problems. How about you fix the 3rd party code instead?
-1 for addition of broken code.
Duly noted :-) It's simple enough and works well in my narrow context, so I'll just keep it to myself. Cheers, - Kim
Am 25.06.2012 20:46, schrieb Kim Gräsman:
Duly noted :-)
It's simple enough and works well in my narrow context, so I'll just keep it to myself.
I'd use a similar approach in your place. Practicality beats purity. Or beat the author of the broken lib with a big stick. :) Christian
It seems to me it would be easier to patch the 3rd party library code and submit the patch to them, than to do this. There are other ways to manipulate the file system to achieve what you are attempting.. but somewhere along the line you would have to interact with another program. If you taught the shell to clean up after your act, then this could be achieved in the event of a power failure. You could even write a wrapper shell for Python. I think perhaps the case is too niche for that kind of solution -- Be prepared to have your predictions come true
participants (4)
-
Christian Heimes -
Christopher Reay -
Ethan Furman -
Kim Gräsman