Ignore:
Timestamp:
Jul 30, 2008, 9:50:42 PM (16 years ago)
Author:
y_z
Message:

added shared/exclusive locking; added shared locking of initial JSON cache read

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-base/files/usr/share/python-support/sipb-xen-base/invirt/common.py

    r790 r793  
    4040    return wrapper
    4141
    42 def with_lock_file(path):
     42def with_lock_file(path, exclusive = True):
    4343    """
    4444    Context manager for lock files.  Example:
     
    5454        @with_closing(file(path, 'w'))
    5555        def g(f):
    56             flock(f, LOCK_EX)
     56            if exclusive: locktype = LOCK_EX
     57            else:         locktype = LOCK_SH
     58            flock(f, locktype)
    5759            try: return func()
    5860            finally: flock(f, LOCK_UN)
Note: See TracChangeset for help on using the changeset viewer.