This file is indexed.

/usr/share/pyshared/jsb/utils/locking.py is in jsonbot 0.84.4-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# jsb/utils/locking.py
#
#

""" locking functions """

## jsb imports

from exception import handle_exception
from trace import whichmodule
from lockmanager import lockmanager, rlockmanager
from jsb.lib.threads import getname

## generic imports

import logging
import sys
import thread

## Locked-class

class Locked(object):

    """ class used to lock an entire object. UNTESTED"""

    def __getattribute__(self, attr):
        where = whichmodule(1)
        logging.debug('locking - locking on %s' % where)
        rlockmanager.acquire(object)
        res = None
        try: res = super(Locked, self).__getattribute__(attr)
        finally: rlockmanager.release(object)
        return res

## lockdec function

def lockdec(lock):
    """ locking decorator. """
    def locked(func):
        """ locking function for %s """ % str(func)
        def lockedfunc(*args, **kwargs):
            """ the locked function. """
            where = whichmodule(2)
            logging.debug('locking - locking on %s' % where)
            lock.acquire()
            res = None
            try: res = func(*args, **kwargs)
            finally:
                try:
                    lock.release()
                    logging.debug('locking - releasing %s' % where)
                except: pass
            return res
        return lockedfunc
    return locked

## locked decorator

def lock_object(object):
    try: locktarget = object.repr()
    except: locktarget = repr(object)
    lockmanager.acquire(locktarget)

def release_object(object):
    try: locktarget = object.repr()
    except: locktarget = repr(object)
    lockmanager.release(locktarget)

def locked(func):
    """ function locking decorator """
    def lockedfunc(*args, **kwargs):
        """ the locked function. """
        where = getname(str(func))
        try:
            rlockmanager.acquire(where)
            res = func(*args, **kwargs)
        finally: rlockmanager.release(where)
        return res
    return lockedfunc

globallock = thread.allocate_lock()
globallocked = lockdec(globallock)