We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.

The posixfile module

(Obsolete, Unix only). This module provides a file-like object with support for file locking. New programs should use the fcntl module instead.

Example: Using the posixfile module
# File: posixfile-example-1.py

import posixfile
import string

filename = "counter.txt"

    # open for update
    file = posixfile.open(filename, "r+")
    counter = int(file.read(6)) + 1
except IOError:
    # create it
    file = posixfile.open(filename, "w")
    counter = 0

file.lock("w|", 6)

file.seek(0) # rewind
file.write("%06d" % counter)

file.close() # releases lock