object.enable() anti-pattern

Cameron Simpson cs at zip.com.au
Thu May 9 04:23:31 EDT 2013


On 09May2013 19:54, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
| Steven D'Aprano wrote:
| >There is no sensible use-case for creating a file without opening
| >it. What would be the point?
| 
| Early unix systems often used this as a form of locking.

Not just early systems: it's a nice lightweight method of making a
lockfile even today if you expect to work over NFS, where not that
many things are synchronous. You open a file with "0" modes, so
that it is _immediately_ not writable. Other attempts to make the
lock file thus fail because of the lack of write, even over NFS.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au>

You can listen to what everybody says, but the fact remains that you've got
to get out there and do the thing yourself.     - Joan Sutherland



More information about the Python-list mailing list