On Tue, 2006-06-27 at 11:15 -0500, Clark Williams wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mike McLean wrote:
> Clark Williams wrote:
>> Not smart enough to argue that we should wait for our build system
>> clients to weigh in. Sigh...
>>
>> Dan/Jeremy/Mike/Andreas/et al
>>
>> How are you going to use file locking? Do you just want mock to lock
>> the status file when we're changing state, or is there something else
>> I'm missing?
>
> Pretty much. The lock is to prevent the watcher from reading a
> partially written status file.
Something like :
flock(fileno, LOCK_EX)
<write new status>
flock(fileno, LOCK_UN)
That what you're looking for?
In python:
import fcntl
lkfd = open(<lockfile_path>, 'w')
rc = fcntl.flock(lkfd, fcntl.LOCK_EX)
<write new status>
fcntl.flock(lkfd, fcntl.LOCK_UN)
close(lkfd)
Yes.
Dan