Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31633
| Date | 2012-10-18 14:14 +0100 |
|---|---|
| Subject | locking files on Linux |
| From | andrea crotti <andrea.crotti.0@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2430.1350566044.27098.python-list@python.org> (permalink) |
I'm trying to understand how I can lock a file while writing on it,
because I might have multiple processes working on it at the same time.
I found the fcntl.lockf function but if I do this:
In [109]: locked = open('locked.txt', 'w')
In [110]: fcntl.lockf(locked, fcntl.LOCK_EX)
I can happily open the file with vim from somewhere and write on it, so
it doesn't seem to be very useful, or am I missing something?
I can otherwise use the classic ".lock" file when working on it, but I
would be glad to see a smarter solution (should only work on Linux)..
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-18 14:14 +0100
Re: locking files on Linux Grant Edwards <invalid@invalid.invalid> - 2012-10-18 13:27 +0000
Re: locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-18 14:44 +0100
Re: locking files on Linux Grant Edwards <invalid@invalid.invalid> - 2012-10-18 13:57 +0000
Re: locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-18 15:49 +0100
Re: locking files on Linux Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-10-18 16:04 +0100
Re: locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-18 16:08 +0100
Re: locking files on Linux Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-10-18 16:31 +0100
Re: locking files on Linux andrea crotti <andrea.crotti.0@gmail.com> - 2012-10-19 13:15 +0100
Re: locking files on Linux Nobody <nobody@nowhere.com> - 2012-10-19 15:36 +0100
Re: locking files on Linux Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2012-10-18 14:58 +0100
csiph-web