KLockFile

KDE 4.2 PyKDE API Reference

- KDE's Python API

# KLockFile Class Reference

`from PyKDE4.kdecore import *`

## Detailed Description

\class KLockFile klockfile.h <KLockFile>

The KLockFile class provides NFS safe lockfiles.

Author:
  Waldo Bastian <bastian@kde.org>

## Enumerations
LockFlag | { NoBlockFlag, ForceFlag } Typesafe wrapper: LockFlags
LockResult | { LockOK, LockFail, LockError, LockStale }
## Methods
| __init__ (self, QString file, KComponentData componentName=KGlobal.mainComponent())
| __init__ (self, KLockFile other)
bool, int (pid), QString (hostname), QString (appname) | getLockInfo (self, )
bool | isLocked (self)
KLockFile.LockResult | lock (self, KLockFile.LockFlags flags=KLockFile.LockFlags())
| setStaleTime (self, int _staleTime)
int | staleTime (self)
| unlock (self)

## Method Documentation

__init__ | ( | self, |
|  | QString | file,
|  | KComponentData | componentName=KGlobal.mainComponent()
| ) |  |  |

__init__ | ( | self, |
|  | KLockFile | other
| ) |  |  |

bool, int (pid), QString (hostname), QString (appname) getLockInfo | ( | self, |
| ) |  |  |

Returns the pid, hostname and appname of the process holding the lock after the lock functon has returned with LockStale.

Returns:
  false if the pid and hostname could not be determined

bool isLocked | ( |  | self ) |

Returns whether the lock is held or not

KLockFile.LockResult lock | ( | self, |
|  | KLockFile.LockFlags | flags=KLockFile.LockFlags()
| ) |  |  |

Attempt to acquire the lock

Parameters:

  | flags | A set of LockFlag values OR'ed together.

setStaleTime | ( | self, |
|  | int | _staleTime
| ) |  |  |

Set the time in seconds after which a lock is considered stale

int staleTime | ( |  | self ) |

Return the time in seconds after which a lock is considered stale The default is 30.

unlock | ( |  | self ) |

Release the lock

## Enumeration Documentation

LockFlag

Return immediately, do not wait for the lock to become available

Note:
  It is necessary to wrap members of this enumeration in a `LockFlags` instance when passing them to a method as group of flags. For example: `LockFlags( NoBlockFlag | ForceFlag)`

Enumerator:

  NoBlockFlag = 1 |
  ForceFlag = 2 |

LockResult

Lock was acquired successfully

Enumerator:

  LockOK = 0 |
  LockFail |
  LockError |
  LockStale |