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
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 = ''
def __init__(self): self.counter = 0 self.lock = RLock()