2012/10/18 Oscar Benjamin oscar.j.benja...@gmail.com:
The lock is cooperative. It does not prevent the file from being
opened or overwritten. It only prevents any other process from
obtaining the lock. Here you open the file with mode 'w' which
truncates the file instantly (without checking
On Thu, 18 Oct 2012 14:44:27 +0100, andrea crotti wrote:
Uhh I see thanks, I guess I'll use the good-old .lock file (even if it
might have some problems too).
In which case, you don't see. A lock file is also advisory, i.e. it only
affects applications which explicitly check for a lock file.
On 2012-10-18, andrea crotti andrea.crott...@gmail.com wrote:
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',
2012/10/18 Grant Edwards invalid@invalid.invalid:
On 2012-10-18, andrea crotti andrea.crott...@gmail.com wrote:
File locks under Unix have historically been advisory. That means
that programs have to _choose_ to pay attention to them. Most
programs do not.
Linux does support mandatory
On 18 October 2012 14:44, andrea crotti andrea.crott...@gmail.com wrote:
2012/10/18 Grant Edwards invalid@invalid.invalid:
On 2012-10-18, andrea crotti andrea.crott...@gmail.com wrote:
File locks under Unix have historically been advisory. That means
that programs have to _choose_ to pay
On 2012-10-18, andrea crotti andrea.crott...@gmail.com wrote:
2012/10/18 Grant Edwards invalid@invalid.invalid:
On 2012-10-18, andrea crotti andrea.crott...@gmail.com wrote:
File locks under Unix have historically been advisory. That means
that programs have to _choose_ to pay attention to
On 18 October 2012 15:49, andrea crotti andrea.crott...@gmail.com wrote:
2012/10/18 Grant Edwards invalid@invalid.invalid:
If what you're guarding against is multiple instances of your
application modifying the file, then either of the advisory file
locking schemes or the separate lock file
2012/10/18 Oscar Benjamin oscar.j.benja...@gmail.com:
Why not come up with a test that actually shows you if it works? Here
are two suggestions:
1) Use time.sleep() so that you know how long the lock is held for.
2) Write different data into the file from each process and see what
you end
On 18 October 2012 16:08, andrea crotti andrea.crott...@gmail.com wrote:
2012/10/18 Oscar Benjamin oscar.j.benja...@gmail.com:
Why not come up with a test that actually shows you if it works? Here
are two suggestions:
1) Use time.sleep() so that you know how long the lock is held for.
2)