Table of Contents

Module: lockfiles ./src/peak/running/

Lockfiles for inter-process communication

These are used for synchronization between processes, unlike thread.LockType locks. The common use is non-blocking lock attempts. For convenience and in order to reduce confusion with the (somewhat odd) thread lock interface, these locks have a different interface.

attempt() try to obtain the lock, return boolean success obtain() wait to obtain the lock, returns None release() release an obtained lock, returns None locked() returns True if any thread IN THIS PROCESS has obtained the lock, else False

In general, you should assume that only the LockFile class will be available. Only use a more-specific lockfile type if you have need of compatibility with non-PEAK software that uses that special type of lockfile. (In practice, this means that the only time you'll ever use anything other than the generic LockFile class is if you need to work with something on a Unix-like platform that uses the equivalent of FLockFile, as SHLockFile is the default implementation of LockFile on Unix-like platforms.)

Currently, only Unix-ish and Windows platforms supported; if your platform isn't supported, not even the LockFile class will be available from this module. For Windows, the msvcrt module must be available (it is in the standard Python 2.2.1 binary distribution for Windows).

This module also exports a NullLockFile class, for use when locking is not needed, but an object with a locking interface is nonetheless required. NullLockFile can also be used as a substitute for a thread lock, if you prefer this locking interface over the standard Python one.

Imported modules   
import errno
from interfaces import ILock
import os
from peak.api import naming, protocols
from peak.naming.factories.openable import FileURL
from peak.util.threads import allocate_lock
import time
check_lock ( fn )

Check the validity of an existing lock file

Reads the PID out of the lock and check if that process exists

make_tempfile ( fn,  pid )

pid_exists ( pid )

Is there a process with PID pid?



flock(3)-based locks.


Common base for lockfiles


Pseudo-LockFile (locks only for threads in this process)


HoneyDanBer/NNTP/shlock(1)-style locking


Like FLockFile, but for Windows


Table of Contents

This document was automatically generated on Mon May 20 01:11:08 2019 by HappyDoc version 2.1