in reply to Re^2: file reading / writing collisions
in thread file reading / writing collisions

flock: "it waits indefinitely until the lock is granted"

I don't know of an easy to do what you want without polling. From the looks of it though, your locks are really short lived, so it should not be a problem.

Update: s/should be/should not be/

  • Comment on Re^3: file reading / writing collisions