KDE 4.9 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 }
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

Enumerator:

  NoBlockFlag = 1 |
  ForceFlag = 2 |

LockResult

Possible return values of the lock function.

Enumerator:

  LockOK = 0 |
  LockFail |
  LockError |
  LockStale |