Sunday, March 29, 2009

file lock on python code

#import the package:

import fcntl

#lock file handle:
fcntl.lockf(logFile.fileno(), fcntl.LOCK_EX|fcntl.LOCK_NB)

#unlock file handle
fcntl.lockf(logFile.fileno(), fcntl.LOCK_UN)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.