Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25229
| Date | 2012-07-12 19:46 +0200 |
|---|---|
| From | Laszlo Nagy <gandalf@shopzeus.com> |
| Subject | Re: How to safely maintain a status file |
| References | <CAOV1wRVtm27yWez1HZuN8=ia-TyM2aXp9QCUbSZ5aZExP_ZChA@mail.gmail.com> <mailman.1917.1341748397.4697.python-list@python.org> <ea62c8fb-fccd-49a6-b715-4749f5fca7ce@s6g2000pbi.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2056.1342116183.4697.python-list@python.org> (permalink) |
>> Windows doesn't suppport atomic renames if the right side exists. I >> suggest that you implement two code paths: >> >> if os.name == "posix": >> rename = os.rename >> else: >> def rename(a, b): >> try: >> os.rename(a, b) >> except OSError, e: >> if e.errno != 183: >> raise >> os.unlink(b) >> os.rename(a, b) > > Problem is if the process is stopped between unlink and rename there > would no status file. Yes, and actually it does not need to be an abnormal termination. It is enough if the OS scheduler puts this process on hold for some time... But using a lock file, the problem can be solved. However in that case, reading a status file can be a blocking operation.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: How to safely maintain a status file Christian Heimes <lists@cheimes.de> - 2012-07-08 13:53 +0200
Re: How to safely maintain a status file Plumo <richardbp@gmail.com> - 2012-07-08 22:50 -0700
Re: How to safely maintain a status file Christian Heimes <lists@cheimes.de> - 2012-07-09 10:17 +0200
Re: How to safely maintain a status file Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-12 19:46 +0200
csiph-web