Python fcntl Test

From PeformIQ Upgrade
Revision as of 18:22, 24 May 2008 by PeterHarding (talk | contribs) (New page: <pre> #! /usr/bin/env python2.2 """Test program for the fcntl C module. Roger E. Masse """ import struct import fcntl import os, sys import datetime curr = datetime.datetime.now() pr...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#! /usr/bin/env python2.2
"""Test program for the fcntl C module.
   Roger E. Masse
"""
import struct
import fcntl
import os, sys

import datetime

curr = datetime.datetime.now()

print curr

sys.exit(0)

filename = sys.argv[1]

# Again, but pass the file rather than numeric descriptor:
f = open(filename, 'a+')

rv = fcntl.flock(f, fcntl.LOCK_EX)

import time

time.sleep (60)

rv = fcntl.flock(f, fcntl.LOCK_UN)

f.close()