in reply to Re: (OT?) File Locking
in thread (OT?) File Locking
For this code
either change LOCK_EX to LOCK_EX|LOCK_NB or just drop the whole loop counting retries because flock(FH,LOCK_EX) simply waits until the lock is obtained.
Also, the seek isn't needed on any platform I know of. Windows needs the locking but already seeks each time you write to a file in append mode (though it certainly won't hurt). And I'd be sure to turn on "autoflush" for the file handle since you are using print to write the data.
- tye (but my friends call me "Tye")
|
|---|