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.
2012/10/18 Oscar Benjamin :
>
> 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 for the lock).
>
>
> Os
On 18 October 2012 16:08, andrea crotti wrote:
> 2012/10/18 Oscar Benjamin :
>>
>> 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 e
2012/10/18 Oscar Benjamin :
>
> 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 up with.
>
Ok thank
On 18 October 2012 15:49, andrea crotti wrote:
> 2012/10/18 Grant Edwards :
>>
>> 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 should work fine.
>
> Ok so I tried a sma
On 2012-10-18, andrea crotti wrote:
> 2012/10/18 Grant Edwards :
>> On 2012-10-18, andrea crotti 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 mandato
On 18 October 2012 14:44, andrea crotti wrote:
> 2012/10/18 Grant Edwards :
>> On 2012-10-18, andrea crotti 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 s
2012/10/18 Grant Edwards :
> On 2012-10-18, andrea crotti 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 locking, but it's rarely used and must be
On 2012-10-18, andrea crotti 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', 'w')
>
> In [110]: f