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:

import posixfile
import string

filename = "counter.txt"

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

file.lock("w|", 6) # rewind
file.write("%06d" % counter)

file.close() # releases lock

A Django site. rendered by a django application. hosted by webfaction.