Package web2py :: Package gluon :: Module portalocker
[hide private]
[frames] | no frames]

Module portalocker

source code


Cross-platform (posix/nt) API for flock-style file locking.

Synopsis:

   import portalocker
   file = open("somefile", "r+")
   portalocker.lock(file, portalocker.LOCK_EX)
   file.seek(12)
   file.write("foo")
   file.close()

If you know what you're doing, you may choose to

   portalocker.unlock(file)

before closing the file, but why?

Methods:

   lock( file, flags )
   unlock( file )

Constants:

   LOCK_EX
   LOCK_SH
   LOCK_NB

I learned the win32 technique for locking files from sample code
provided by John Nielsen <nielsenjf@my-deja.com> in the documentation
that accompanies the win32 modules.

Author: Jonathan Feinberg <jdf@pobox.com>
Version: $Id: portalocker.py,v 1.3 2001/05/29 18:47:55 Administrator Exp $



Functions [hide private]
 
lock(file, flags) source code
 
unlock(file) source code
Variables [hide private]
  logger = logging.getLogger("web2py")
  os_locking = 'posix'
  __overlapped = pywintypes.OVERLAPPED()
  LOCK_EX = 1
PyMySQL: A pure-Python drop-in replacement for MySQLdb.
  LOCK_SH = 1
PyMySQL: A pure-Python drop-in replacement for MySQLdb.
  LOCK_NB = 1
PyMySQL: A pure-Python drop-in replacement for MySQLdb.