Package portage :: Module locks
[hide private]

Module locks

source code

Classes [hide private]
  basestring
str(object='') -> string
Functions [hide private]
 
_close_fds()
This is intended to be called after a fork, in order to close file descriptors for locks held by the parent process.
source code
 
lockdir(mydir, flags=0) source code
 
unlockdir(mylock) source code
 
lockfile(mypath, wantnewlockfile=0, unlinkfile=0, waiting_msg=None, flags=0)
If wantnewlockfile is True then this creates a lockfile in the parent directory as the file: '.' + basename + '.portage_lockfile'.
source code
Integer
_fstat_nlink(fd)
Returns: the current number of hardlinks to the file
source code
 
unlockfile(mytuple) source code
 
hardlock_name(path) source code
 
hardlink_is_mine(link, lock) source code
 
hardlink_lockfile(lockfilename, max_wait=<type 'exceptions.DeprecationWarning'>, waiting_msg=None, flags=0)
Does the NFS, hardlink shuffle to ensure locking on the disk.
source code
 
unhardlink_lockfile(lockfilename, unlinkfile=True) source code
 
hardlock_cleanup(path, remove_all_locks=False) source code
Variables [hide private]
  HARDLINK_FD = -2
  _HARDLINK_POLL_LATENCY = 3
  _quiet = False
  _open_fds = set([])
  __package__ = 'portage'

Imports: errno, fcntl, platform, sys, time, warnings, portage, os, _encodings, _unicode_decode, DirectoryNotFound, FileNotFound, InvalidData, TryAgain, OperationNotPermitted, PermissionDenied, ReadOnlyFileSystem, writemsg, _, _default_lock_fn


Function Details [hide private]

_close_fds()

source code 

This is intended to be called after a fork, in order to close file descriptors for locks held by the parent process. This can be called safely after a fork without exec, unlike the _setup_pipes close_fds behavior.

_fstat_nlink(fd)

source code 
Parameters:
  • fd (Integer) - an open file descriptor
Returns: Integer
the current number of hardlinks to the file

hardlink_lockfile(lockfilename, max_wait=<type 'exceptions.DeprecationWarning'>, waiting_msg=None, flags=0)

source code 

Does the NFS, hardlink shuffle to ensure locking on the disk. We create a PRIVATE hardlink to the real lockfile, that is just a placeholder on the disk. If our file can 2 references, then we have the lock. :) Otherwise we lather, rise, and repeat.