Module Expr Str Assign NameStore ListLoad Str Str Str Str Str Str Import alias ImportFrom alias ClassDef bases NameLoad body Assign NameStore Num decorator_list If CompareEq AttributeLoad NameLoad attr Str body Import alias Import alias Import alias Assign NameStore AttributeLoad NameLoad attr Assign NameStore Num Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr orelse If CompareEq AttributeLoad NameLoad attr Str body Import alias Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr orelse Raise NameLoad Str FunctionDef arguments args NameParam defaults body Expr Str If Call NameLoad NameLoad Str body Return Call AttributeLoad NameLoad attr orelse If CompareEq Call NameLoad NameLoad NameLoad body Return NameLoad orelse Raise Call NameLoad BinOpMod Str Call NameLoad NameLoad decorator_list If CompareEq AttributeLoad NameLoad attr Str body FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad TryExcept body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Num Num NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr name NameStore body If CompareEq SubscriptLoad NameLoad Index Num Num body Raise Call NameLoad AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num orelse Raise decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad TryExcept body Expr Call AttributeLoad NameLoad attr NameLoad Num Num NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr name NameStore body If CompareEq SubscriptLoad NameLoad Index Num Num body Pass orelse Raise decorator_list orelse If CompareEq AttributeLoad NameLoad attr Str body FunctionDef arguments args NameParam NameParam defaults body TryExcept body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad handlers ExceptHandler type NameLoad name NameStore body If CompareEq SubscriptLoad NameLoad Index Num Num body Raise Call NameLoad AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num orelse Raise decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad NameLoad attr decorator_list If CompareEq NameLoad Str body ImportFrom alias alias alias Import alias Import alias Assign NameStore Call NameLoad Str Str Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Assign NameStore Call NameLoad Str Call NameLoad Call NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Print Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr
N/A N/A 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

Exceptions:

    LockException

Notes:

For the 'nt' platform, this module requires the Python Extensions for Windows.
Be aware that this may not work as expected on Windows 95/98/ME.

History:

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>,
        Lowell Alleman <lalleman@mfps.com>
Version: $Id: portalocker.py 5488 2008-05-21 20:49:38Z lowell $


http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65203
 N/A __all__ N/A lock unlock LOCK_EX LOCK_SH LOCK_NB LockException N/A os types IntType LockException N/A Exception N/A N/A LOCK_FAILED 1 N/A N/A N/A N/A os name nt N/A N/A win32con N/A win32file N/A pywintypes N/A LOCK_EX N/A win32con LOCKFILE_EXCLUSIVE_LOCK N/A LOCK_SH 0 N/A LOCK_NB N/A win32con LOCKFILE_FAIL_IMMEDIATELY N/A __overlapped N/A N/A pywintypes OVERLAPPED N/A N/A N/A N/A os name posix N/A N/A fcntl N/A LOCK_EX N/A fcntl LOCK_EX N/A LOCK_SH N/A fcntl LOCK_SH N/A LOCK_NB N/A fcntl LOCK_NB N/A N/A RuntimeError PortaLocker only defined for nt and posix platforms _getfd N/A N/A file N/A N/A N/A  Get a file-descriptor from a file object or file-descriptor.  N/A N/A hasattr file fileno N/A N/A N/A N/A file fileno N/A N/A N/A N/A type file IntType N/A N/A file N/A N/A N/A TypeError N/A File object or file descriptor required, but %s was provided. N/A type file N/A N/A N/A N/A os name nt N/A lock N/A N/A file flags N/A N/A N/A hfile N/A N/A win32file _get_osfhandle N/A _getfd file N/A N/A N/A N/A N/A win32file LockFileEx hfile flags 0 -65536 __overlapped N/A N/A N/A N/A pywintypes error N/A exc_value N/A N/A N/A N/A exc_value N/A 0 33 N/A N/A N/A LockException N/A LockException LOCK_FAILED N/A exc_value N/A 2 N/A N/A N/A unlock N/A N/A file N/A N/A N/A hfile N/A N/A win32file _get_osfhandle N/A _getfd file N/A N/A N/A N/A N/A win32file UnlockFileEx hfile 0 -65536 __overlapped N/A N/A N/A N/A pywintypes error N/A exc_value N/A N/A N/A N/A exc_value N/A 0 158 N/A N/A N/A N/A N/A N/A N/A N/A N/A os name posix N/A lock N/A N/A file flags N/A N/A N/A N/A N/A N/A N/A fcntl flock N/A _getfd file flags N/A N/A N/A IOError N/A exc_value N/A N/A N/A N/A exc_value N/A 0 11 N/A N/A N/A LockException N/A LockException LOCK_FAILED N/A exc_value N/A 1 N/A N/A N/A unlock N/A N/A file N/A N/A N/A N/A N/A fcntl flock N/A _getfd file N/A fcntl LOCK_UN N/A N/A N/A __name__ __main__ N/A time time strftime localtime N/A sys N/A portalocker N/A log N/A open log.txt a+ N/A N/A N/A portalocker lock log N/A portalocker LOCK_EX N/A timestamp N/A strftime %m/%d/%Y %H:%M:%S
 N/A localtime N/A time N/A N/A N/A log write timestamp N/A Wrote lines. Hit enter to release lock. N/A dummy N/A N/A N/A sys stdin readline N/A N/A N/A log close