Example #1
0
class ConnectionCounter:
    '''Connection Counter.
    '''
    def __init__(self):
        self.counter = 0
        self.lock = RLock()

    def inclement(self):
        try:
            self.lock.acquire(True)
            self.counter += 1
        finally:
            self.lock.release()

    def declement(self):
        try:
            self.lock.acquire(True)
            self.counter -= 1
        finally:
            self.lock.release()

    def __int__(self):
        return self.counter
Example #2
0
class ConnectionCounter:
    '''Connection Counter.
    '''
    def __init__(self):
        self.counter = 0
        self.lock = RLock()

    def inclement(self):
        try:
            self.lock.acquire(True)
            self.counter += 1
        finally:
            self.lock.release()

    def declement(self):
        try:
            self.lock.acquire(True)
            self.counter -= 1
        finally:
            self.lock.release()

    def __int__(self):
        return self.counter
Example #3
0
import config
import spam
import title
from node import *
from tag import *
from tiedobj import *

try:
    import PIL.Image
except ImportError:
    PIL = None
    sys.stdout.write('system does not have PIL.\n')

__all__ = ['Record', 'Cache', 'CacheList', 'UpdateList', 'RecentList']

lock = RLock()


def fsdiff(f, s):
    '''Diff between file and string.

    Return same data or not.
    '''
    try:
        if os.path.isfile(f):
            buf = file(f, 'rb').read()
        else:
            buf = ''
    except (IOError, OSError), e:
        sys.stderr.write('%s: %s\n' % (f, e))
        buf = ''
Example #4
0
 def __init__(self):
     self.counter = 0
     self.lock = RLock()
Example #5
0
 def __init__(self):
     self.counter = 0
     self.lock = RLock()